说明:
LPTSTR GetCommandLine(VOID);

LPWSTR * CommandLineToArgvW(
                                                             LPCWSTR lpCmdLine,  // pointer to a command-line string
                                                             int *pNumArgs       // receives the argument count
                                                           );

使用GetCommandLine函数的返回值是一个程序的命令行,包括进程本身和所有的参数。他和winmain函数的lpCmdLine值是一样的,至于在main函数中,由于main函数可以带argc

,argv参数。这两个参数,argc表示函数的参数,至少为1,argv是二级指针,里面存有所有的参数列表。当argc为1时,argv存储的是函数本身的路径。但main函数里的参数都是ANSI版本的,为了得到对应的Unicode版本的参数列表,所以有了CommandLineToArgvW函数,使用CommandLineToArgvW可以得到相同的效果。只不过是Unicode版本。
例如,可以这样调用:

int dwArgcs = 0;
    LPWSTR *pStr = CommandLineToArgvW(GetCommandLine(), &dwArgcs);

则,dwArgcs就相当于main函数中的argc,pStr就相当于main函数中的argv。
不过要注意了,

CommandLineToArgvW 返回的指针指向的地址空间是在函数内部所分配的,所以,最后的调用GlobalFree释放空间

GetCommandLine CmdLineToArgvW的更多相关文章

  1. 玩转Windows服务系列——Debug、Release版本的注册和卸载,及其原理

    Windows服务Debug版本 注册 Services.exe -regserver 卸载 Services.exe -unregserver Windows服务Release版本 注册 Servi ...

  2. 大数据之Oozie——源码分析(一)程序入口

    工作中发现在oozie中使用sqoop与在shell中直接调度sqoop性能上有很大的差异.为了更深入的探索其中的缘由,开始了oozie的源码分析之路.今天第一天阅读源码,由于没有编译成功,不能运行测 ...

  3. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

  4. Notepad++源码编译及其分析

    Notepad++是一个小巧精悍的编辑器,其使用方法我就不多说了,由于notepad++是使用c++封装的windows句柄以及api来实现的,因此对于其源码的研究有助于学习如何封装自己简单的库(当然 ...

  5. 获取系统中所有进程&线程信息

    读书笔记--[计算机病毒解密与对抗] 目录: 遍历进程&线程程序 终止进程 获取进程信息 获取进程内模块信息 获取进程命令行参数 代码运行环境:Win7 x64 VS2012 Update3 ...

  6. C++ I/O stream

    C++ I/O stream Ø The first, you should understand following: ... Ø Text: Ø Version: Visual studio 20 ...

  7. 常用的WinAPI函数整理

    常用的WinAPI函数整理 一.进程  创建进程:    CreateProcess("C:\\windows\\notepad.exe",0,0,0,0,0,0,0,&s ...

  8. Windows编程入门程序详解

    引用:http://blog.csdn.net/jarvischu/article/details/8115390 1.     程序 /******************************* ...

  9. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

随机推荐

  1. Android开发 MediaPlayer播放raw资源MP3文件

    代码 private MediaPlayer mRingPlayer; /** * 播放铃声 */ private void startRing(){ if (mRingPlayer != null) ...

  2. linux zip,tar压缩文件夹 忽略 .git 文件夾

    linux zip 忽略 .git 文件夾 # zip 命令 zip -r bitvolution.zip bitvolution -x *.git* # tar命令压缩文件夹忽略 .git文件夹 t ...

  3. CSIC_716_20191106【列表、元组、字典、集合】

    python的数据类型及其内置方法 一.列表(续) list.count( ).list.index( ) list = ['1', '2', '3', '2', 'a', 'b', 'c', 'a' ...

  4. css---2D变形

    1.transfrom:rotate(360deg); 用前要加transition: 2s;                      deg重点 transform:rotate(angle); ...

  5. 2016.8.15上午纪中初中部NOIP普及组比赛

    2016.8.15上午纪中初中部NOIP普及组比赛 链接:https://jzoj.net/junior/#contest/home/1333 这次比赛不怎么好,因为这套题目我并不是很擅长. 可同学们 ...

  6. 最大流dicnic——hdu1532模板题

    #include<bits/stdc++.h> using namespace std; #define maxn 1005 #define ll long long const ll i ...

  7. kubernetes istio的快速安装和使用例子

    安装 [root@master ~]# wget https://github.com/istio/istio/releases/download/1.1.5/istio-1.1.5-linux.ta ...

  8. c# 中xml序列化时相同节点存入不同类型值

    先上需要序列话的类定义: [System.Xml.Serialization.XmlIncludeAttribute(typeof(DescriptionType))] [System.CodeDom ...

  9. 导入数据时出现“SqlDateTime 溢出

    错误出现:导入数据时出现“SqlDateTime 溢出.必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM之间.” 出现这种问题多半是因为你插入或者更 ...

  10. PAT甲级——A1117 Eddington Number【25】

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...