• <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
            數(shù)據(jù)加載中……

            WinMain支持命令行參數(shù)的代碼

             

            #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支持命令行參數(shù)的代碼

            #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(); //獲取命令行參數(shù);
                    
                    lpszArgv 
            = ::CommandLineToArgvW((const unsigned short *)szCmdLine, &argc); //拆分命令行參數(shù)字符串;
                    

                    
                    
            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);
                            
            //下面是獲取命令行參數(shù)值的典型用法:
                        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 閱讀(651) 評論(0)  編輯 收藏 引用

            人妻少妇久久中文字幕一区二区| 久久人人爽爽爽人久久久| 久久e热在这里只有国产中文精品99| 97久久久精品综合88久久| 国产91久久综合| 久久天天躁狠狠躁夜夜躁2014| 亚洲精品乱码久久久久久 | 国产精品岛国久久久久| 久久精品国产精品亚洲下载| 亚洲中文字幕无码久久精品1| 香蕉久久一区二区不卡无毒影院| 亚洲国产成人久久一区WWW| 狠色狠色狠狠色综合久久| 久久久亚洲AV波多野结衣| 国产成人香蕉久久久久| 久久久久无码精品国产| 久久久久波多野结衣高潮| 国产精品一久久香蕉国产线看| 欧美精品丝袜久久久中文字幕| 久久国产精品成人免费| 伊人久久一区二区三区无码| 亚洲精品国产成人99久久| 精品久久8x国产免费观看| 99精品国产综合久久久久五月天| 久久精品国产亚洲Aⅴ香蕉| 91亚洲国产成人久久精品网址| 久久婷婷五月综合色高清 | 久久婷婷五月综合成人D啪| 精品免费tv久久久久久久| 久久精品中文字幕无码绿巨人| 伊人久久大香线蕉av不变影院| 亚洲精品国产自在久久| 蜜臀久久99精品久久久久久| 久久精品无码免费不卡| 久久影院亚洲一区| 久久综合久久性久99毛片| 亚洲国产日韩欧美综合久久| 欧美亚洲日本久久精品| 欧美成人免费观看久久| 亚洲午夜久久久| 久久久久亚洲av无码专区喷水|