未分类--Windows API--CommandLineToArgvW

来源:互联网 发布:手机淘宝怎么实名验证 编辑:程序博客网 时间:2024/05/02 04:46

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件643166601@qq.com

 

CommandLineToArgvW Function

--------------------------------------------------------------------------------

Parses a Unicode command line string and returns an array of null-terminated Unicode strings.
解析一个Unicode命令行字符串并且返回一个以null结尾的Unicode字符串数组。
The strings contain the individual arguments found in that command line, and a count of arguments, similar to the standard C run-time argv and argc values.
这个字符串包含在命令行中单独的参数,和参数的计数,类似于标准C运行时的argv 和 argc值。
Syntax

LPWSTR *CommandLineToArgvW(         
LPCWSTR lpCmdLine,
int *pNumArgs
);
Parameters

lpCmdLine
[in] A pointer to a null-terminated Unicode string containing the full command line.
一个指向以null结尾的Unicode字符串包含在完整的命令行。
An application will usually directly pass on the value returned by a call to the GetCommandLineW function.
一个应用程序将通常通过调用GetCommandLineW函数的返回值直接传递。
If this parameter is the empty string (""), the function returns the path to the current executable file.
如果这个参数是一个空字符串(""),这个函数返回当前可执行文件的路径。
pNumArgs
[out] A pointer to a variable of type int that receives the number of array elements returned.
一个指针指向int类型的变量它取回返回数组的数量。
Return Value

A pointer to an array of null-terminated Unicode strings representing the individual arguments found on the command line.
一个指针指向以null结尾的Unicode字符串数组代表这个独立参数在命令上找到。
The first element contains the program name; each subsequent element contains one argument.
这个第一个元素包含程序名称,随后的每个元素包含一个参数。
If the function fails, the return value is NULL.
如果这个函数失败,返回值是NULL。
To get extended error information, call GetLastError.
去获得额外的错误信息请调用GetLastError。

Remarks

The calling application must free the memory used by the argument list when it is no longer needed.
当它不再需要时这个调用应用程序必须由使用的参数列表释放内存。
To free the memory, use a single call to the LocalFree function.
去释放内存,使用一个单独的LocalFree函数。
This function accepts command lines containing a program name; the program name can be enclosed in quotation marks or not.
这个函数接收命令行包含一个程序名称,这个程序名称可以在扩在引号内也可以没有。
CommandLineToArgvW has a special interpretation of backslash characters when they are followed by a quotation mark character ("), as follows:
当它们通过引号字符(")时CommandLineToArgvW有一个指定的反斜杠字符解释,如下
2n backslashes followed by a quotation mark produce n backslashes followed by a quotation mark.
2n个反斜杠后续通过一个引号产生n个反斜杠跟着一个引号
(2n) + 1 backslashes followed by a quotation mark again produce n backslashes followed by a quotation mark.
(2n) + 1 个反斜杠后续一个引号再一次产生n个反斜杠跟着是一个引号。
n backslashes not followed by a quotation mark simply produce n backslashes.
n个反斜杠不能后序一个引号类似长生n个反斜杠。
Example

The following example demonstrates how to parse a Unicode command-line string. The code frees the memory for the argument list at exit.

Show Example

#include <windows.h>
#include <stdio.h>
#include <shellapi.h>

int __cdecl main()
{
   LPWSTR *szArglist;
   int nArgs;
   int i;

   szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
   if( NULL == szArglist )
   {
      wprintf(L"CommandLineToArgvW failed\n");
      return 0;
   }
   else for( i=0; i<nArgs; i++) printf("%d: %ws\n", i, szArglist[i]);

// Free memory allocated for CommandLineToArgvW arguments.

   LocalFree(szArglist);

   return(1);
}
Function Information

Minimum DLL Version Shell32.dll version 6.0 or later
Custom Implementation No
Header Shellapi.h
Import library Shell32.lib
Minimum operating systems Windows NT Workstation 3.5, Windows NT Server 3.5, Windows 2000 Professional, Windows 2000 Server, Windows XP, Windows Server 2003
Unicode Implemented as Unicode version.

 

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 红豆沙馅太稀了怎么办 买的豆沙馅太稀怎么办 做的豆馅稀了怎么办 包豆沙包馅稀了怎么办 软件自定义权限重名怎么办 窗户外有垃圾桶怎么办 菜地里有蚂蚁怎么办 灯光吸引的飞虫怎么办 广告机格式化了怎么办 proe约束冲突了怎么办 中午考试想睡觉怎么办 喝了红茶睡不着怎么办 考试前状态不好怎么办 考前紧张睡不着觉怎么办 通宵失眠第二天怎么办 考试前睡不着觉怎么办 一到晚上睡不着怎么办 明天考试听力差怎么办 天天晚上睡不着觉怎么办 因紧张睡不着觉怎么办 房卡找不到了怎么办 马代不会英文怎么办 剩下的蒸米饭怎么办 临时牌照违法了怎么办 打12345不管用怎么办 省政府改变了中央文件怎么办 应聘时学历不够怎么办 做导游学历不够怎么办 市长热线打不通怎么办 12315网站不受理怎么办 法律文书生效前转后财产怎么办 打12345投诉没用怎么办 单位医保停了怎么办 iphonex开不了机怎么办 会计证三年没检怎么办 银行工作人员态度不好怎么办 生殖保健服务证怎么办 关机后自动开机怎么办 大连卖房户口怎么办 在警务室被辅警骂了怎么办 上海微信怎么办居住证