文链接 -> 传送门
函数功能:
GetCommandLine 函数用于获得当前进程的命令行字符串。
API 函数原型:
LPTSTR WINAPI GetCommandLine(void);
参数解析:
这个函数没有参数。
返回值:
返回值是一个指向当前进程命令行字符串的指针。
备注:
1. 用 ANSI C 编写的控制台程序可以使用的 main 函数的 argc 和 argv 参数访问命令行参数。 ANSI GUI 应用程序可以使用 WinMain 函数的参数 lpCmdLine 访问命令行字符串,不包括程序名称。main,WinMain 函数不能返回 Unicode 字符串。
2. 用 C 语言编写的 Unicode 控制台程序可以使用 wmain 或 _tmain 函数访问命令行参数。Unicode 的 GUI 应用程序必须使用 GetCommandLineW 函数来访问 Unicode 字符串。
3. 要将命令行转换为字符串风格数组 argv,请调用 CommandLineToArgvW 函数。
需求:
|
Minimum supported client |
Windows XP [仅桌面应用程序 | Windows 商店应用程序] |
|
Minimum supported server |
Windows 2003 服务器版 [仅桌面应用程序 | Windows 商店应用程序] |
|
Header |
1. 在 Windows XP, Windows Server 2003、Windows Vista、Windows 7、Windows Server 2008 和 Windows Server 2008 R2 系统上是 WinBase.h(包含于 Windows.h); |
|
Library |
Kernel32.lib |
|
DLL |
Kernel32.dll |
|
Unicode and ANSI names |
GetCommandLineW (Unicode) 和 GetCommandLineA (ANSI) |




