function GetClass(
Handle: integer):
string;
var
Buf:
array[0..255]
of char;
begin
GetClassName(
Handle,Buf,255);
Result := Buf;
end;
function HandleToPid(
Handle: integer): integer;
var
PID: dword;
begin
GetWindowThreadProcessId(
Handle,Pid);
Result := Pid;
end;
function PidToPath(Pid: integer):
string;
var
ProcessHandle: THandle;
Buf:
array[0..MAX_PATH]
of char;
begin
ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION
or PROCESS_VM_READ, false,Pid);
GetModuleFileNameEx(ProcessHandle,0,Buf,MAX_PATH);
Result :=
String(Buf);
CloseHandle(ProcessHandle);
end;
function GetCaption(
Handle: integer):
string;
var
Buf:
array[0..255]
of char;
begin
GetWindowText(
Handle,Buf,255);
Result := Buf;
end;
function eWindows(
Handle: integer; Num: Integer): bool;
stdcall;
var
IncludeHidden:
string;
IncludeVisible:
string;
begin
IncludeVisible := inttostr(Num);
IncludeHidden := copy(IncludeVisible,1,1);
Delete(IncludeVisible,1,1);
if IncludeVisible = '
1'
then if iswindowvisible(
Handle)
then begin
WindowListing := WindowListing + inttostr(
Handle) + '
|' + GetCaption(
Handle) + '
|' + GetClass(
Handle) + '
|' + PidToPath(HandleToPid(
Handle)) + '
|' + inttostr(HandleToPid(
Handle)) + #13#10;
end;
if IncludeHidden = '
1'
then if not iswindowvisible(
Handle)
then begin
WindowListing := WindowListing + inttostr(
Handle) + '
|' + GetCaption(
Handle) + '
|' + GetClass(
Handle) + '
|' + PidToPath(HandleToPid(
Handle)) + '
|' + inttostr(HandleToPid(
Handle)) + #13#10;
end;
Result := True;
end;
function WindowList(Number:
string):
string;
begin
WindowListing := '
';
EnumWindows(@eWindows,strtoint(number));
Result := WindowListing;
end;