Win32开发(命令行参数处理)

int n_args = 0;  
    LPWSTR *args = CommandLineToArgvW(GetCommandLineW(), &n_args);  
  
    if( args )  
    {  
        if( n_args >= 2 ) {  
            std::wstring filePath = L"";  
            auto last_prm = aux::chars_of(args[n_args - 1]);  
            if( last_prm.like(L"*\\*") || last_prm.like(L"*/*") )  
            {  
                if( last_prm.like(L"\"*\"") )  
                    filePath = std::wstring( last_prm.start + 1, last_prm.end() - 1);  
                else  
                    filePath = std::wstring( last_prm.start, last_prm.end());  
            }  
            g_FilePath = AsStringUtil::Wchar_t2String(filePath.c_str());  
            g_FilePath.append("test.json");  
      
        }  
        LocalFree(args);  
    } else {  
        return 0;  
    }  

posted on 2014-04-10 15:07  Yours风之恋  阅读(289)  评论(0编辑  收藏  举报