forked from Ox18/cheatmatrix-gunbound
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumUnit.pas
More file actions
64 lines (47 loc) · 1.41 KB
/
EnumUnit.pas
File metadata and controls
64 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
unit EnumUnit;
interface
uses windows, sysutils, TlHelp32, classes;
function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;
Function CM_EnumWindows(Lista: TStrings): boolean;
Function CM_EnumProcesses(Lista: TStrings): boolean;
implementation
Function CM_EnumProcesses(Lista: TStrings): boolean;
var pe: TProcessEntry32;
thSnapshot: THandle;
retval,ProcFound: boolean;
begin
result := false;
thSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(thSnapshot = INVALID_HANDLE_VALUE) then
begin
exit;
end;
pe.dwSize := sizeof(PROCESSENTRY32);
retval := Process32First(thSnapshot, pe);
Lista.Clear;
while(retval) do
begin
Lista.Add(FormatFloat('000000',pe.th32ProcessID)+' - '+Trim(pe.szExeFile));
retval := Process32Next(thSnapshot, pe);
pe.dwSize := sizeof(PROCESSENTRY32);
end;
result := true;
end;
Function CM_EnumWindows(Lista: TStrings): boolean;
begin
Lista.Clear;
EnumWindows(@EnumWindowsFunc, LParam(Lista));
end;
function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;
var Caption: array[0..256] of Char;
pid: cardinal;
begin
result := false;
if GetWindowText(Handle, Caption, SizeOf(Caption)-1) <> 0 then
begin
GetWindowThreadProcessId(Handle,@pid);
List.Add(FormatFloat('000000', pid)+' - '+ Caption);
end;
Result :=True;
end;
end.