打开一个进程的方法
#include <Windows.h>
#include <iostream>
using namespace std;
int main()
{
STARTUPINFO startupInfo = { 0 };
PROCESS_INFORMATION processInformation = { 0 };
bool bSuccess = CreateProcess(TEXT("C:/Windows/notepad.exe"), NULL, NULL, NULL, false, NULL, NULL, NULL, &startupInfo, &processInformation);
if (bSuccess)
{
cout << "Process started." << endl << "process ID:\t" << processInformation.dwProcessId << endl;
}
else
{
cout << "error:" << GetLastError() << endl;
}
int ms = 0;
cout << "please kill process:";
cin >> ms;
if (ms = 1)
{
ExitProcess(0);
}
else
{
cout << "no user"<<endl;
}