一个正执行的程序如何启动另一新程序并关闭现执行程序

最简单的方法有两个函数即可实现:

 

//启动新程序
WinExec("存放另一新程序的路径", SW_SHOW);
//关闭现执行软件

 ExitThread(0);

 

 

若在win ce 下,用WinExec这个函数就不对了,那时就应该用ShellExecuteEx了。

 SHELLEXECUTEINFO ShExecInfo;

 ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
 ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS ;
 ShExecInfo.hwnd = NULL;
 ShExecInfo.lpVerb = NULL;
 ShExecInfo.lpFile = _T("//Program Files//Amtps//Amtps.exe");
 ShExecInfo.lpParameters = _T("");
 ShExecInfo.lpDirectory = NULL;
 ShExecInfo.nShow = SW_SHOW;
 ShExecInfo.hInstApp = NULL;

 ShellExecuteEx(&ShExecInfo);

你可能感兴趣的:(Software,Development)