如果下面的代码是利用了CWinApp保存的命令行字符串的话: CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line.  Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;那么问题来了,是什么样的过程,把命令行参数保存到了CWinApp对象里面? MFC的框架如何保存这个命令行参数的?

解决方案 »

  1.   

    CWinApp没有保存命令行参数,你不是用的CCommandLineInfo保存分解后的参数么?
      

  2.   

    CCommandLineInfo的ctor并没有从哪里去取命令行参数啊。
    怎么解释?
      

  3.   

    有取参数的过程,但是....
    void CWinApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)
    {
    for (int i = 1; i < __argc; i++)
    {
    LPCTSTR pszParam = __targv[i];
    BOOL bFlag = FALSE;
    BOOL bLast = ((i + 1) == __argc);
    if (pszParam[0] == '-' || pszParam[0] == '/')
    {
    // remove flag specifier
    bFlag = TRUE;
    ++pszParam;
    }
    rCmdInfo.ParseParam(pszParam, bFlag, bLast);
    }
    }
    现在问题又来了,__targv以及__argc从哪里来呢?
    这些值的定义不在MFC源文件以及MFC头文件里,难道是C++的全局变量/全局函数?