unit UnitPHG;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,
{ ShellAPI,} TLHelp32;
type
TForm1 =
class(TForm)
Button1: TButton;
PLiveTicker: TPanel;
PPartyWindowProcessID: TPanel;
Label1: TLabel;
PPartyWindowClassName: TPanel;
PPartyWindowHandle: TPanel;
Label2: TLabel;
Label3: TLabel;
Panel1: TPanel;
Label4: TLabel;
PPartyWindowExe: TPanel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
WM_ENUMERATE_ID: integer;
public
{ Public-Deklarationen }
procedure WriteText(Wnd: HWnd);
procedure WndProc(
var Message: TMessage);
override;
end;
var
Form1: TForm1;
// get a messageID from Windows
function RegisterMessage: integer;
// this is the callbackfunction. Don't miss stdcall
// can't be part of the form.
function EnumWinProc(Wnd: HWnd; param: lParam): boolean;
stdcall;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// get our msgID
WM_ENUMERATE_ID:= RegisterMessage;
end;
function RegisterMessage: integer;
begin
Result:= RegisterWindowMessage('
Enumerate this Window');
end;
function EnumWinProc(Wnd: HWnd; param: lParam): boolean;
stdcall;
var iMsgID: integer;
begin
iMsgID:= RegisterMessage;
// give data to main form
SendMessage(param, iMsgID, 0, Wnd);
Result:=true;
end;
procedure TForm1.WndProc(
var Message: TMessage);
begin
if Message.Msg=WM_ENUMERATE_ID
then
// oh! Enumerate Window found a window, lets do something
WriteText(
Message.lParam)
else
inherited WndProc(
Message);
end;
//fill in the listview with all the information
procedure TForm1.WriteText(Wnd: HWnd);
var pcWinText : PChar;
Str:
string;
aProcessEntry32 : TProcessEntry32;
aSnapshotHandle : THandle;
WinVersion : DWord;
ProcessID : longint;
ContinueLoop : boolean;
begin
{WindowCaption ermitteln}
pcWinText:= StrAlloc(102);
GetWindowText(Wnd, pcWinText, 100);
if Pos('
PartyPoker.com:',StrPas(pcWinText))<>0
then
begin
Panel1.Caption:=StrPas(pcWinText);
StrDispose(pcWinText);
{WindowClassName ermitteln}
pcWinText:= StrAlloc(102);
GetClassName(Wnd, pcWinText, 100);
PPartyWindowClassName.Caption :=StrPas(pcWinText);
StrDispose(pcWinText);
{WindowHandle ermitteln}
PPartyWindowHandle.Caption :=IntToHex(wnd, 8);
{WindowThreadProcessID}
GetWindowThreadProcessID(wnd,@ProcessID);
PPartyWindowProcessID.Caption:=IntToHex(ProcessID, 8);
{Weiter: Speicher auslesen: GetMemoryList(ProcessID);}
end;
{According to Christian Kästner: Bestimmt die exe-Datei}
aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
aProcessEntry32.dwSize := Sizeof(aProcessEntry32);
ContinueLoop := Process32First(aSnapshotHandle, aProcessEntry32);
while integer(ContinueLoop) <> 0
do begin
if aProcessEntry32.th32ProcessID = ProcessID
then
PPartyWindowExe.Caption:=(ExtractFileName(aProcessEntry32.szExeFile));
ContinueLoop := Process32Next(aSnapshotHandle,aProcessEntry32);
end;
CloseHandle(aSnapshotHandle);
{end of Chrstian's stuff}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// start EnumerateWindows, send the Handle of the Form
// so function nows where to send the info
EnumWindows(@EnumWinProc, self.Handle);
end;
end.