两种进程开启方法

来源:互联网 发布:网络教育好考吗 编辑:程序博客网 时间:2024/05/19 21:16

void CProcess1Dlg::OnButton1()
{
 // TODO: Add your control notification handler code here

 CreateProcess(L"//BMPCHANGE.exe",NULL,NULL,NULL,FALSE,CREATE_NEW_CONSOLE,NULL,NULL,NULL,&proinfo);
 CloseHandle(proinfo.hProcess);
 CloseHandle(proinfo.hThread);
}

void CProcess1Dlg::OnButtonClose1()
{
 // TODO: Add your control notification handler code here
 HANDLE handle = OpenProcess(0,FALSE,proinfo.dwProcessId);
 TerminateProcess(handle,0);
 DWORD dw;
 GetExitCodeProcess(handle,&dw);
 if (dw == 0)
 {
  MessageBox(L"Close1");
 }
}


void CProcess1Dlg::OnButton2()
{
 // TODO: Add your control notification handler code here

 shellinfo.cbSize = sizeof(SHELLEXECUTEINFO);
 shellinfo.lpFile = L"//BMPCHANGE.exe"; 
 shellinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
 shellinfo.lpVerb = L"Open";
 shellinfo.nShow = SW_SHOW;
 shellinfo.hInstApp = 0; 
 shellinfo.hkeyClass = 0;
 shellinfo.hProcess = 0;
 shellinfo.hwnd = 0;
 shellinfo.lpClass = 0;
 shellinfo.dwHotKey = 0;
 shellinfo.hIcon = 0;
 shellinfo.lpDirectory = NULL;
 shellinfo.lpIDList = 0;
 shellinfo.lpParameters = NULL;
 ShellExecuteEx(&shellinfo);
}

void CProcess1Dlg::OnButton4()
{
 // TODO: Add your control notification handler code here
 TerminateProcess(shellinfo.hProcess,0);
}

原创粉丝点击