您的位置:首页 > 其它

EVC进程获取启动参数

2010-01-16 10:46 411 查看
在A程序中调用B程序,并传入参数aa bb cc dd ee,我们可以用如下方法实现:

1.在A程序中创建B进程

CreateProcess(L"//B.exe", L"aa bb cc dd ee",0,0,0,0,0,0,0,0);


2.在B程序中可以通过下列方式获得A传入的参数

CString temp;
temp=::GetCommandLineW();
AfxMessageBox(temp);


temp中的内容为aa bb cc dd ee.

EVC下的GetCommandLine和VC下的不一样。

int   argc=0;
LPWSTR   *argv=::CommandLineToArgvW(::GetCommandLineW(),&argc);
for(int   i=0;i<argc;i++)
{
CString   msg=argv[i];
MessageBox(msg,"Information");
}


上面代码将依次得到当前进程的路径(相对路径)和传入的参数。其中EVC不支持CommandLineToArgvW函数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: