DelPhi 2020. 4. 12. 13:44

function Ch4ckPr0c4(Process: String): Boolean;

var

ContinueLoop: BOOL;

FSnapshotHandle: THandle;

FProcessEntry32: TProcessEntry32;

begin

Result := False;

FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

FProcessEntry32.dwSize := Sizeof(FProcessEntry32);

ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);

while Integer(ContinueLoop) <> 0 do

begin

if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))

= UpperCase(Process)) or (UpperCase(FProcessEntry32.szExeFile)

= UpperCase(Process))) then

begin

PID := FProcessEntry32.th32ProcessID;

if PID <> 0 then

begin

HandleWindow := OpenProcess(PROCESS_ALL_ACCESS, False, PID);

Result := True;

Break;

end;

end;

ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);

end;

CloseHandle(FSnapshotHandle);

end;

posted by 핵커 커뮤니티
: