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

            国产精品久久久福利| 三级三级久久三级久久| 94久久国产乱子伦精品免费| 精品久久久久久无码中文字幕一区| 久久精品免费观看| 色欲综合久久躁天天躁| 久久久久99精品成人片试看| 免费观看成人久久网免费观看| 三级韩国一区久久二区综合| 久久综合给合久久狠狠狠97色69 | 国产精品成人久久久久久久| 久久99热这里只有精品国产| 亚洲精品高清国产一线久久| 狠狠人妻久久久久久综合| 午夜视频久久久久一区 | 老司机午夜网站国内精品久久久久久久久 | 久久青草国产精品一区| 久久精品无码一区二区WWW| 久久九九全国免费| 久久大香香蕉国产| 99久久国产精品免费一区二区| 99久久亚洲综合精品成人| 浪潮AV色综合久久天堂| 亚洲精品无码久久久久AV麻豆| 99久久99这里只有免费的精品| 亚洲欧美另类日本久久国产真实乱对白| 狼狼综合久久久久综合网| 国内精品人妻无码久久久影院导航| 精品国产一区二区三区久久蜜臀| 久久se精品一区精品二区| 久久精品国产亚洲AV无码偷窥| 伊人久久大香线蕉亚洲五月天 | 亚洲精品国产综合久久一线| 久久精品国产亚洲精品| 91久久精品视频| 成人国内精品久久久久一区| 中文字幕久久波多野结衣av| 久久精品国产久精国产一老狼| 亚洲欧美国产日韩综合久久| 伊人精品久久久久7777| 国产99久久久国产精品小说|