1.派生自己的类 CCommandLineInfo 2. BOOL CMarkupApp::InitInstance() { ... // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; ... return TRUE; }
The GetAddressByName function queries a name space, or a set of default name spaces, in order to obtain network address information for a specified network service. This process is known as service name resolution. A network service can also use the function to obtain local address information that it can use with the bind function.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
2.
BOOL CMarkupApp::InitInstance()
{
... // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; ... return TRUE;
}
ParseCommandLine(cmdInfo);
可以处理常规的参数很方便,如打开文件,打印等...
但如果要使用自定义的参数就不行了。
如果你使用CWinApp作为你的应用程序基类可以在CWinApp::m_lpCmdLine中找到命令行字符串,而后随便你怎么解析。