• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            tqsheng

            go.....
            隨筆 - 366, 文章 - 18, 評論 - 101, 引用 - 0
            數據加載中……

            WinMain支持命令行參數的代碼

             

            #include "stdafx.h"
            #include 
            <STRING.h>
            #include 
            <STDIO.H>
            int APIENTRY WinMain(HINSTANCE hInstance,
                                 HINSTANCE hPrevInstance,
                                 LPSTR     lpCmdLine,
                                 
            int       nCmdShow)
            {
                 
            // TODO: Place code here.
                char *pCmdLine = GetCommandLine();
                
            char  sep[] = " ";
                
            char *token = NULL;
                
            char  argv[10][10= {0};
                
            int      argc = 0;
                
                token 
            = strtok(pCmdLine,sep);
                
            while (token != NULL)
                {
                    strcpy(argv[argc
            ++],token);
                    OutputDebugString(token);
                    token 
            = strtok(NULL,sep);
                }
                
            return 0;
            }


            WinMain支持命令行參數的代碼

            #include <windows.h>
            #include 
            <stdio.h>

            int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd)
            {
                    
            //for the command line;
                    
                    
            int argc = 0;
                    
                    LPWSTR 
            *lpszArgv = NULL;

                    
                    LPWSTR szCmdLine 
            =(LPWSTR)::GetCommandLineW(); //獲取命令行參數;
                    
                    lpszArgv 
            = ::CommandLineToArgvW((const unsigned short *)szCmdLine, &argc); //拆分命令行參數字符串;
                    

                    
                    
            if (lpszArgv == NULL)
                    {
                    
                            MessageBox(NULL, 
            "Unable to parse command line""Error", MB_OK);
                            
            return 10;
                    }
                    
                    
            for(int i = 0; i < argc; i++)

                    {
                            
            char   str[MAX_PATH];
                            memset(str,
            0,MAX_PATH);
                    
            //將LPWSTR轉換為char *:
                    WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,lpszArgv[i], -1,str,200,NULL,NULL);
                    MessageBox(NULL,str, 
            "Arglist contents", MB_OK);
                        
                    }
                    
                    LocalFree(lpszArgv);
                    
            return 0;
            }


            一個簡單的 方法用stdlib.h中的__argc,__argv

            #include <windows.h>
            #include 
            <stdlib.h>

            int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd)
            {
                    
            //for the command line;
                    for(int i = 0; i <__argc; i++)

                    {
                            
            char   str[MAX_PATH];
                            
            char * str1;
                            memset(str,
            0,MAX_PATH);
                            
            //下面是獲取命令行參數值的典型用法:
                        lstrcpy(str,__argv[i]);
                            str1
            =strdup(__argv[i]);
                        
            //MessageBox(NULL,str, "Arglist contents", MB_OK);
                            MessageBox(NULL,str1, "Arglist contents", MB_OK);
                        
                    }
                    
            return 0;
            }





             

            posted on 2012-03-30 07:01 tqsheng 閱讀(648) 評論(0)  編輯 收藏 引用

            亚洲∧v久久久无码精品| 狠狠色丁香久久婷婷综合五月 | 久久久久久精品免费免费自慰| 久久只有这精品99| 久久精品中文字幕无码绿巨人| 精品乱码久久久久久夜夜嗨| 国内精品久久久久影院老司| 72种姿势欧美久久久久大黄蕉| 久久国产香蕉一区精品| 久久亚洲精品国产精品| 中文成人久久久久影院免费观看| 97精品伊人久久大香线蕉app| 九九久久精品国产| 亚洲精品国产字幕久久不卡| 中文字幕亚洲综合久久| 成人综合伊人五月婷久久| 久久噜噜久久久精品66| 久久中文精品无码中文字幕| 久久久久亚洲精品无码蜜桃| 久久综合伊人77777麻豆| 色综合久久综合网观看| 亚洲一区二区三区日本久久九| 99久久综合国产精品免费| 久久黄视频| 国产精品亚洲美女久久久| 精品久久人人爽天天玩人人妻 | 伊人久久综合热线大杳蕉下载| 久久天天婷婷五月俺也去| 久久91这里精品国产2020| 四虎国产精品免费久久5151| 99久久er这里只有精品18| 无码久久精品国产亚洲Av影片| 亚洲日本久久久午夜精品| 香蕉久久AⅤ一区二区三区| 久久精品国产只有精品66 | 久久久精品日本一区二区三区| 狠色狠色狠狠色综合久久| 久久免费线看线看| 伊人色综合久久| 久久天天躁狠狠躁夜夜2020老熟妇| 久久高潮一级毛片免费|