OpenProcess咋不能打开进程(自己开的)啊,返回值尽然是000000
///////////////////////////////////////////////////////////////// 02TerminateProcess.cpp文件
#include "stdafx.h"
#include <windows.h>
#include<iostream>
using namespace std;
BOOL TerminateProcessFromId(DWORD dwId)
{
BOOL bRet = FALSE;
// 打开目标进程,取得进程句柄
HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwId);cout<<hProcess<<endl;
if(hProcess != NULL)
{printf(" 终止1! \n");
// 终止进程
bRet = ::TerminateProcess(hProcess, 0);
}
CloseHandle(hProcess);
return bRet;
}
int main(int argc, char* argv[])
{
DWORD dwId;
printf(" 请输入您要终止的进程的ID号: \n");
scanf("%u", &dwId);
if(TerminateProcessFromId(dwId))
{
printf(" 终止进程成功! \n");
}
else
{
printf(" 终止进程失败! \n");
}
system("PAUSE");
return 0;
}