.
.
var
Global_HookHandle : HWND = 0;
Global_WinAmpHandle : HWND = 0;
Global_HookInstalled : Boolean = false;
function AmpHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
begin
if (wParam = IPC_SETVOLUME)
then asm
NOP;
// Just for debugging purpose
end;
Result := CallNextHookEx(Global_HookHandle, nCode, wParam, lParam);
end;
function GlobalUnInstallHook:Boolean;
stdcall;
begin
//Hook aus der Hookchain entfernen
Global_HookInstalled := UnhookWindowsHookEx(Global_HookHandle);
if not(Global_HookInstalled)
then begin
Global_HookHandle := 0;
Global_WinAmpHandle := 0;
end;
Result := Global_HookInstalled;
end;
function GlobalInstallHook:Boolean;
stdcall;
var
TID : DWORD;
// Thread ID
PID : LPDWORD;
// Process ID -- Just for Testing with Sysinternals ProcessExplorer
begin
Result := no;
if (Global_HookHandle=0)
then begin
{$WARNINGS OFF}
new(PID);
TID := GetWindowThreadProcessId(Global_WinAmpHandle,PID);
Global_HookHandle := SetWindowsHookEx(WH_CALLWNDPROCRET,@AmpHookProc, 0, TID);
Global_HookInstalled := (Global_HookHandle<>0);
Result := Global_HookInstalled;
dispose(PID);
{$WARNINGS ON}
end;
end;
.
.
procedure TForm2.FindWinamp;
begin
Global_WinAmpHandle := FindWindow('
Winamp v1.x',
nil);
WinampRunning := (Global_WinAmpHandle<>0);
end;