• <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)  編輯 收藏 引用

            国产精品青草久久久久婷婷 | 亚洲欧洲中文日韩久久AV乱码| 国内精品久久久久伊人av| 久久精品国产亚洲AV忘忧草18| 久久人人超碰精品CAOPOREN| 久久久久综合国产欧美一区二区 | 久久精品国产色蜜蜜麻豆| 色欲综合久久中文字幕网 | 久久久亚洲裙底偷窥综合| 久久综合给久久狠狠97色| 久久中文娱乐网| 日韩精品久久久久久久电影蜜臀| 欧美久久综合性欧美| 少妇无套内谢久久久久| 久久伊人中文无码| 国产综合精品久久亚洲| 久久精品国产亚洲一区二区| 综合久久一区二区三区 | 2021国内久久精品| 欧美久久一级内射wwwwww.| 久久99热只有频精品8| 久久久久国产一区二区三区| 欧美一区二区三区久久综| 色婷婷综合久久久中文字幕| 亚洲精品tv久久久久久久久| 一本一本久久a久久精品综合麻豆| 国产69精品久久久久9999| 国产精品久久久久jk制服| 日产精品99久久久久久| av无码久久久久久不卡网站| 久久久亚洲欧洲日产国码二区| 国产午夜免费高清久久影院| 91精品国产综合久久婷婷| 久久久免费观成人影院 | 99久久亚洲综合精品成人| 精品久久人人爽天天玩人人妻 | 精品无码久久久久久国产| 亚洲AV成人无码久久精品老人| 91精品婷婷国产综合久久| 伊色综合久久之综合久久| 精品综合久久久久久97超人|