__getmainargs、__wgetmainargs__getmainargs, __wgetmainargs

调用命令行解析,并通过传递的指针将参数复制到 main()Invokes command-line parsing and copies the arguments to main() back through the passed pointers.

语法Syntax

int __getmainargs(  
    int * _Argc,   
   char *** _Argv,   
   char *** _Env,   
   int _DoWildCard,  
_startupinfo * _StartInfo);  

 int __wgetmainargs (  
   int *_Argc,  
   wchar_t ***_Argv,  
   wchar_t ***_Env,  
   int _DoWildCard,  
   _startupinfo * _StartInfo)  

参数Parameters

_Argc
包含 argv 后面的参数数的整数。An integer that contains the number of arguments that follow in argv. argc 参数始终大于或等于 1。The argc parameter is always greater than or equal to 1.

_Argv
表示由杂注用户输入的命令行自变量的以 null 结尾的字符串的数组。An array of null-terminated strings representing command-line arguments entered by the user of the program. 按照约定,argv[0] 是用于调用程序的命令,argv[1] 是第一个命令行参数,依此类推,直到 argv[argc](其始终为 NULL)。By convention, argv[0] is the command with which the program is invoked, argv[1] is the first command-line argument, and so on, until argv[argc], which is always NULL. 第一个命令行参数始终是 argv[1],而最后一个命令行参数是 argv[argc - 1]The first command-line argument is always argv[1] and the last one is argv[argc - 1].

_Env
表示用户环境中的变量集的字符串数组。An array of strings that represent the variables set in the user's environment. 该数组由 NULL 项终止。This array is terminated by a NULL entry.

_DoWildCard
一个整数,如果将其设置为 1,则扩展命令行自变量中的通配符;如果设置为 0,则不执行任何操作。An integer that if set to 1 expands the wildcards in the command line arguments, or if set to 0 does nothing.

_StartInfo
要传递给 CRT DLL 的其他信息。Other information to be passed to the CRT DLL.

返回值Return Value

如果成功,则为 0;如果失败,则为负值。0 if successful; a negative value if unsuccessful.

备注Remarks

在非宽字符平台上使用 __getmainargs,并且在宽字符 (Unicode) 平台上使用 __wgetmainargsUse __getmainargs on non-wide character platforms, and __wgetmainargs on wide-character (Unicode) platforms.

要求Requirements

例程Routine 必需的标头Required header
__getmainargs__getmainargs internal.hinternal.h
__wgetmainargs__wgetmainargs internal.hinternal.h