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

            久久亚洲AV成人出白浆无码国产| 久久偷看各类wc女厕嘘嘘| 久久99国产精品久久99| 久久精品中文字幕有码| 丰满少妇高潮惨叫久久久| 日韩精品久久久久久久电影| 日韩一区二区久久久久久| 欧美熟妇另类久久久久久不卡 | 午夜精品久久久久| 久久亚洲精精品中文字幕| 久久国产精品免费| 久久国产视频99电影| 久久久噜噜噜久久熟女AA片| 亚洲精品乱码久久久久久久久久久久| 精品久久久久一区二区三区| 久久天天躁狠狠躁夜夜avapp| 国产精品va久久久久久久| 99久久99久久精品国产片| 久久99久久成人免费播放| 久久久国产乱子伦精品作者| 中文字幕无码久久人妻| 亚洲av伊人久久综合密臀性色| 国产成人精品久久亚洲高清不卡| 久久成人国产精品免费软件| 国产亚洲精午夜久久久久久| A狠狠久久蜜臀婷色中文网| 狠狠精品久久久无码中文字幕 | 久久精品成人免费国产片小草| 久久久无码一区二区三区| 奇米综合四色77777久久| 国产精品久久久久久久久久影院 | 94久久国产乱子伦精品免费| …久久精品99久久香蕉国产| 99久久婷婷国产一区二区 | 热综合一本伊人久久精品| 欧美日韩久久中文字幕| 中文字幕精品久久| 精品久久久无码21p发布| 无码八A片人妻少妇久久| 伊人久久大香线蕉亚洲五月天| 久久久久波多野结衣高潮|