strtok函数取WinMain的参数
生活随笔
收集整理的這篇文章主要介紹了
strtok函数取WinMain的参数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
WinMain函數與main函數不同,main可以從argc得到函數個數,然后從argv[]數組里取參數。
而WinMain函數取參數是通過lpCmdLine,lpCmdLine里不能得到參數的個數。
下面使用strtok來將參數分開。
int WINAPI WinMain(HINSTANCE hInstance, // handle to current instanceHINSTANCE hPrevInstance, // handle to previous instanceLPSTR lpCmdLine, // command lineint nCmdShow // show state) {char strCmdLine[MAX_PATH];strcpy(strCmdLine,lpCmdLine);//找到第一個參數,IP地址char *pstrParam;pstrParam = strtok(strCmdLine," ");if (pstrParam){MessageBoxA(0,pstrParam,"IP",0);//找到第二個參數,端口pstrParam = strtok(NULL," ");if(pstrParam) MessageBoxA(0,pstrParam,"Port",0);} }與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
以上是生活随笔為你收集整理的strtok函数取WinMain的参数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于KernelFaultCheck启动
- 下一篇: 框架挂马