基于对话框的应用程序如何获取入口参数?例如 p1.exe -abc -cd   这时在p1中如何知道用户输入了abc 及cd 呢? 请指点?最好有个例子.

解决方案 »

  1.   

    用GetCommandLine()就可以了。
      

  2.   

    BOOL CHddAgingApp::InitInstance()
    {
    ..........CString cmd;
    cmd = m_lpCmdLine;
    //If no parameter, open the main window
    if(!cmd.CompareNoCase(""))
    {
    ........
    } //Define the command content
    int dwCount;
    LPWSTR *lpwArgv = NULL;
    lpwArgv = CommandLineToArgvW(GetCommandLineW(), &dwCount); //Get help information
    if(dwCount == 2)
    {
    if((!_wcsnicmp(lpwArgv[1], L"/H", 2) || !_wcsnicmp(lpwArgv[1], L"/?", 2)))
    ....
    }
      

  3.   

    得到第一个参数__argv[ 0 ],第二个__argv[ 1 ],第三个__argv[ 2 ]参数的总个数是__argc