如何封锁除本身措施外的所有其他应用措施
获恰当前激活的历程:
1:包括头文件tlhelp32.h
2:.cpp如下:
ListView2->Items->Clear();
TListItem *mItem;
AnsiString ExeFile;
Pointer pt,pt2;
unsigned int s;
DWORD size,size2;
HANDLE snapshot;
PROCESSENTRY32 processinfo;
processinfo.dwSize = sizeof(processinfo);
snapshot =
CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (snapshot==NULL) return;
bool flag = Process32First (snapshot,&processinfo);
while (flag)
{
mItem=ListView2->Items->Add();
ExeFile=AnsiString(processinfo.szExeFile);
mItem->Caption=ExeFile;
mItem->SubItems->Add(IntToStr(int(processinfo.th32ParentProcessID)));
mItem->SubItems->Add(IntToHex(int(processinfo.th32ProcessID),8).UpperCase());
size=GetFileVersionInfoSize(ExeFile.c_str(),&size2);
pt=malloc(size);
GetFileVersionInfo(ExeFile.c_str(),NULL,size,pt);
if(VerQueryValue(pt,"\\StringFileInfo\\040904E4\\FileVersion",&pt2,&s))
mItem->SubItems->Add(PChar(pt2));
if(VerQueryValue(pt,"\\StringFileInfo\\040904E4\\CompanyName",&pt2,&s))
mItem->SubItems->Add(PChar(pt2));
if(VerQueryValue(pt,"\\StringFileInfo\\040904E4\\FileDescription",&pt2,&s))
mItem->SubItems->Add(PChar(pt2));
free(pt);
flag = Process32Next(snapshot,&processinfo);
}
要杀除一个历程,必需得到该历程的父线成ID(制止仅仅杀除子历程)。
if (ListView2->SelCount==0)
{
MessageBox(Handle,"请首先选择一个历程!","中止历程",MB_OK|MB_ICONWARNING);
return;
}
int pPid=StrToInt(ListView2->Selected->SubItems->Strings[0]);
HANDLE ps = OpenProcess(1,false,pPid);
if(ps&&TerminateProcess(ps,-9))
{
MessageBox(Handle,"乐成中止历程!","中止历程",MB_OK|MB_ICONINFORMATION);
}
else
MessageBox(Handle,"中止历程失败!","中止历程",MB_OK|MB_ICONWARNING);
ViewProcess();