• <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 閱讀(635) 評論(0)  編輯 收藏 引用

            一本色道久久综合狠狠躁| 韩国三级中文字幕hd久久精品| 亚洲精品乱码久久久久久| 麻豆av久久av盛宴av| 久久久久人妻精品一区二区三区 | 久久久网中文字幕| 一本一本久久a久久综合精品蜜桃 一本一道久久综合狠狠老 | 久久精品久久久久观看99水蜜桃 | 91麻豆国产精品91久久久| 久久久久亚洲精品天堂| 国产成人99久久亚洲综合精品| 日韩久久久久中文字幕人妻| 亚洲国产精品无码久久SM| 久久免费国产精品一区二区| 亚洲?V乱码久久精品蜜桃| 久久超碰97人人做人人爱| 久久精品无码av| 久久香蕉超碰97国产精品| 99久久久久| 无遮挡粉嫩小泬久久久久久久| 日本免费一区二区久久人人澡 | 久久久免费观成人影院| 久久久久亚洲AV无码网站| 色婷婷久久久SWAG精品| 丰满少妇高潮惨叫久久久| 一日本道伊人久久综合影| 亚洲国产精品婷婷久久| 亚洲国产精品无码久久98| 久久精品18| 国产韩国精品一区二区三区久久| 伊人久久大香线蕉无码麻豆| 久久精品国产精品青草app| 国产毛片欧美毛片久久久 | 无码国内精品久久人妻| 久久国产精品无码网站| 亚洲精品美女久久777777| 国产成人久久激情91| 亚洲日韩中文无码久久| 人妻中文久久久久| Xx性欧美肥妇精品久久久久久| 久久无码人妻一区二区三区|