void StartSubApplication(CString strExeFilePath, CString strExeFileName, CString strCaption)
{
CWnd* pWndPrev = CWnd::FindWindow(NULL, strCaption); if (pWndPrev != NULL)
{
pWndPrev->BringWindowToTop();
}
else
{
strExeFilePath = GetFullPath(strExeFilePath); CString strExeFile = strExeFilePath + "\\" + strExeFileName; PROCESS_INFORMATION p; STARTUPINFO StartupInfo = {{sizeof(StartupInfo)}, {NULL}, {NULL}, {NULL}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {STARTF_FORCEONFEEDBACK}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}}; CreateProcess(NULL, strExeFile.GetBuffer(255), NULL, NULL, false, 0, NULL, strExeFilePath, &StartupInfo, &p); WaitForInputIdle(p.hProcess, INFINITE);
}
}
{
CWnd* pWndPrev = CWnd::FindWindow(NULL, strCaption); if (pWndPrev != NULL)
{
pWndPrev->BringWindowToTop();
}
else
{
strExeFilePath = GetFullPath(strExeFilePath); CString strExeFile = strExeFilePath + "\\" + strExeFileName; PROCESS_INFORMATION p; STARTUPINFO StartupInfo = {{sizeof(StartupInfo)}, {NULL}, {NULL}, {NULL}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {STARTF_FORCEONFEEDBACK}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}}; CreateProcess(NULL, strExeFile.GetBuffer(255), NULL, NULL, false, 0, NULL, strExeFilePath, &StartupInfo, &p); WaitForInputIdle(p.hProcess, INFINITE);
}
}
1.可以使用ShellExecute调用外部的程序。
::ShellExecute(NULL,NULL,_T("Project1.exe"),NULL, strPath ,SW_SHOW );
其中的strPath就是可执行文件所在的目录.
2.可以使用createprocess来调用外部的程序。