欢迎访问Ningto's博客

Menu
  • 首页
  • 归档
  • 关于
  • 书签
  • 必应壁纸
  • IT聚合
  • 工具
    • 我的工具列表
    • 我的网盘
    • 必应每日壁纸API
    • Html转Markdown
    • 仙尘光标
Menu

分离WinMain中传进来的字符串(迁移2011-01-14)

最后更新 2017-01-22 12:59:50   阅读量 1689

我们知道WinMain函数是可以接受外部字符串的, 但是它获取的是整个字符串, 如果要获取多个字符串, 就必须把源字符串分离开, 下面是MSDN里介绍的方法:

#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]);
   }
   LocalFree(szArglist);
   return(1);
}

(转载本站文章请注明作者和出处:泞途 - ningto.com)

下一篇 –  scanf、sscanf中的正则表达式(迁移2011-01-14)
上一篇 – WTL自画按钮与文件对话框(迁移2011-01-14)

  1. Windows

toningto@outlook.com

推荐文章

QProcess 7z.exe 解压进度

IE获取元素样式

标签云

IOS Life Qt Node.js Design Android Tools Product Bug Shell Mobile Go Web Javascript Mac Windows Linux React MQ Others Boost C/C++ MongoDB Tips Python Java Database

推广链接

【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元

多谢支持,用了好几年,服务很稳定支持多设备!

其他

文章RSS

Copyright © 2016 Welcome To Ningto Blog | 鄂ICP备17003086号-2