Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Probleme mit WinAmp Hook (https://www.delphipraxis.net/113810-probleme-mit-winamp-hook.html)

LoCrux 15. Mai 2008 07:42


Probleme mit WinAmp Hook
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hi @All,

vielleicht kann mir einer helfen. Ich will einen Message-Hook auf WinAmp.
Funzt aber nicht. Bekomme als Global_HookHandle immer nur 0, Zero, Null, NADA ...
Vielleicht weiss einer Rat.

Delphi-Quellcode:
.
.
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;
Bevor die Frage kommt warum... Ich will ein Frontend fuer WinAmp selber schreiben.. Warum CarPC Bedienoberflaeche mit Touchscreen..
Warum.. Alles was es gibt gefaellt mir nicht oder ist zu teuer.

(P.S. vielleicht hat ja jemand Lust mit einzusteigen..:-))

EIDTS: Falsche Fehler

EWeiss 15. Mai 2008 08:36

Re: Probleme mit WinAmp Hook
 
Weiss nicht obs was bringt aber versuchs doch mal mit Watch..
Mit sicherheit sind einige Hilfreiche infos darin enthalten.

gruss Emil

LoCrux 15. Mai 2008 08:47

Re: Probleme mit WinAmp Hook
 
AEHHHH... WATCH..????

EWeiss 15. Mai 2008 09:01

Re: Probleme mit WinAmp Hook
 
Zitat:

Zitat von LoCrux
AEHHHH... WATCH..????

hmmmm http://www.bome.com/delphi/

gruss Emil

LoCrux 15. Mai 2008 10:30

Re: Probleme mit WinAmp Hook
 
AHHHHHH!!!! :-D

Wotan89 15. Mai 2008 11:26

Re: Probleme mit WinAmp Hook
 
Wenn ich mich nicht täusche musst du bei SetWindowsHookEx beim 3.Parameter HInstance (wenn sich dein Quelltext in einer DLL befindet) übergeben, sonst weiß er nicht in welchem Modul sich deine Funktion befindet. Ich kann mich aber auch irren.

LoCrux 16. Mai 2008 00:41

Re: Probleme mit WinAmp Hook
 
@Wotan

Zitat:

Zitat von Wotan
Wenn ich mich nicht täusche musst du bei SetWindowsHookEx beim 3.Parameter HInstance (wenn sich dein Quelltext in einer DLL befindet) übergeben, sonst weiß er nicht in welchem Modul sich deine Funktion befindet. Ich kann mich aber auch irren.

Du irrst dich nicht :-), meine Hook-Proc liegt alledings im aufrufenden Process.

Zitat:

Zitat von MSDN
Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

Also daran liegts nicht...

EDIT:

P.S.:
Ich werde auf die Bass.dll wechseln. Wuerde aber trotzdem gerne wissen, warum der Hook nicht hakt :-)

Wotan89 17. Mai 2008 11:47

Re: Probleme mit WinAmp Hook
 
Ich hab die Variante noch nicht probiert, dass sie im aufrufenden Prozess liegt, daher denke ich, dass die Hook-Proc in einer DLL liegen muss, denn sonst können andere Prozesse nicht auf diese Funktion zugreifen... Zumindest fände ich es unlogisch, wenn dies nicht der Fall wäre.


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz