char chPath[301];
::GetCurrentDirectory(300,(LPTSTR)chPath);//得到当前目录
char path[200]= "\\123.exe";
strcat(chPath,path);
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
// Start the child process
if(CreateProcess(chPath, "", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
else
{
AfxMessageBox(“创建失败!”);
HANDLE hProcess = GetCurrentProcess();//get current process
TerminateProcess(hProcess,0); //close process
}