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;  
    }  

原文地址:https://www.cnblogs.com/wjchang/p/3671667.html