赞
踩
在一个主进程中,调用别的子进程时有两种方法:
1)使用CreateProcess
2)使用ShellExecute
上面这两种方法均可调用别的进程的.exe,在调用.exe的同时还可以给该子进程传递参数。
其中,子进程中获取命令参数的方法大致有以下三种:
1)::GetCommandLine()
使用方法:
CString str = ::GetCommandLine()
2) AfxGetApp()->m_lpCmdLine
CWinApp *thisApp = AfxGetApp();
CString strCmdLine = thisApp->m_lpCmdLine;
3)for (int i=0;i<__argc;i++)
{
__argv[i];
}
依次获取
其中:GetCommandLine()与AfxGetApp()->m_lpCmdLine是有区别的
AfxGetApp()->m_lpCmdLine只可以获取到ShellExecute传过来的参数。
::GetCommandLine() 则都可以。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。