<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Windows Hook zu Winamp]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich versuche fieberhaft einen Windows Hook in Winamp einzuklinken, um in meiner Applikationen die Winamp Messages zu empfangen, bekomme es aber einfach nicht hin. Meine Callback Funktion wird nie aufgerufen.</p>
<p>(Das PostMessage könnt ihr erstmal vergessen; hatte eine MessageBox eingebaut; anstatt von WH_CALLWNDPROC hatte ich auch schon WH_CALLWNDPROCRET und WH_GETMESSAGE eingebaut. bei den ersten beiden ist nichts passiert, bei GetMessage hat sich in der Winamp GUI nichts mehr getan, bis ich meine Applikation geschlossen hab, die Callback-Funktion wurde trotzdem nicht aufgerufen.)</p>
<p>Hier mein Code, er befindet sich in einer dll, die eigentliche Applikationen in einem anderen Projekt:</p>
<pre><code>HHOOK hWinampHook = NULL;
HANDLE hInstance;
HWND hTargetWnd = NULL;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved )
{
	switch( ul_reason_for_call )
	{
        case DLL_PROCESS_ATTACH:
            hInstance = (HINSTANCE)hModule; 
            break; 
        case DLL_THREAD_ATTACH:
            break; 
        case DLL_PROCESS_DETACH:
            break; 
        case DLL_THREAD_DETACH:
            break; 
	}

    return TRUE;
}

LRESULT CALLBACK HookWinampWnd(
	int nCode,      // handle to window
	WPARAM wParam,  // first message parameter
	LPARAM lParam   // second message parameter
)
{
	PostMessage(hTargetWnd, WM_WINAMP, NULL, NULL);

	// pass to next hook
	return CallNextHookEx(NULL, nCode, wParam, lParam);
}

void SetHook(HWND hMainWnd)
{
	hTargetWnd = hMainWnd;

	// get winamp handle
	HWND hwndWinamp = ::FindWindow(&quot;Winamp v1.x&quot;,0);
	if(hwndWinamp == NULL)
	{
		return;
	}

	DWORD dwWAThreadId = GetWindowThreadProcessId( hwndWinamp, NULL );

	hWinampHook = SetWindowsHookEx(
		WH_CALLWNDPROC,
		(HOOKPROC) HookWinampWnd,
		(HINSTANCE)hInstance, 
		dwWAThreadId);
}
</code></pre>
<p>Wäre super wenn hier jemand einen Fehler entdeckt.</p>
<p>Danke und schönen Gruß</p>
<p>MrFlow</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/198565/windows-hook-zu-winamp</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 03:56:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198565.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Nov 2007 19:54:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Windows Hook zu Winamp on Thu, 22 Nov 2007 19:54:15 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich versuche fieberhaft einen Windows Hook in Winamp einzuklinken, um in meiner Applikationen die Winamp Messages zu empfangen, bekomme es aber einfach nicht hin. Meine Callback Funktion wird nie aufgerufen.</p>
<p>(Das PostMessage könnt ihr erstmal vergessen; hatte eine MessageBox eingebaut; anstatt von WH_CALLWNDPROC hatte ich auch schon WH_CALLWNDPROCRET und WH_GETMESSAGE eingebaut. bei den ersten beiden ist nichts passiert, bei GetMessage hat sich in der Winamp GUI nichts mehr getan, bis ich meine Applikation geschlossen hab, die Callback-Funktion wurde trotzdem nicht aufgerufen.)</p>
<p>Hier mein Code, er befindet sich in einer dll, die eigentliche Applikationen in einem anderen Projekt:</p>
<pre><code>HHOOK hWinampHook = NULL;
HANDLE hInstance;
HWND hTargetWnd = NULL;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved )
{
	switch( ul_reason_for_call )
	{
        case DLL_PROCESS_ATTACH:
            hInstance = (HINSTANCE)hModule; 
            break; 
        case DLL_THREAD_ATTACH:
            break; 
        case DLL_PROCESS_DETACH:
            break; 
        case DLL_THREAD_DETACH:
            break; 
	}

    return TRUE;
}

LRESULT CALLBACK HookWinampWnd(
	int nCode,      // handle to window
	WPARAM wParam,  // first message parameter
	LPARAM lParam   // second message parameter
)
{
	PostMessage(hTargetWnd, WM_WINAMP, NULL, NULL);

	// pass to next hook
	return CallNextHookEx(NULL, nCode, wParam, lParam);
}

void SetHook(HWND hMainWnd)
{
	hTargetWnd = hMainWnd;

	// get winamp handle
	HWND hwndWinamp = ::FindWindow(&quot;Winamp v1.x&quot;,0);
	if(hwndWinamp == NULL)
	{
		return;
	}

	DWORD dwWAThreadId = GetWindowThreadProcessId( hwndWinamp, NULL );

	hWinampHook = SetWindowsHookEx(
		WH_CALLWNDPROC,
		(HOOKPROC) HookWinampWnd,
		(HINSTANCE)hInstance, 
		dwWAThreadId);
}
</code></pre>
<p>Wäre super wenn hier jemand einen Fehler entdeckt.</p>
<p>Danke und schönen Gruß</p>
<p>MrFlow</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1408444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1408444</guid><dc:creator><![CDATA[MrFlow]]></dc:creator><pubDate>Thu, 22 Nov 2007 19:54:15 GMT</pubDate></item></channel></rss>