【发布时间】:2015-05-20 19:53:58
【问题描述】:
我在 Visual Studio 中建立了一个 SDI 应用程序。我知道将文件名传递给应用程序就像在命令行中一样:MyApp.exe "C:\a.txt"。但是,它不接受自定义参数或 URL。说我不能做MyApp.exe "SomethingILike" 或MyApp.exe "www.google.com"
我了解处理参数的代码在...App::InitInstance()有
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
显然ProcessShellCommand 排除了 MFC 认为不合理的论点。我应该如何处理我的自定义参数?假设我想通过“SomethingILike”,现在它告诉我文件未找到并关闭,但至少我希望应用程序正常启动并且我将有机会获得
this->m_lpCmdLine
我不能注释掉ProcessShellCommand if 语句,否则它会给我一个未处理的异常。可能ProcessShellCommand 也做了一些初始化工作,这对我来说听起来不太合理。
【问题讨论】: