<?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[Fehler beim Laden von DLL-Funktionen]]></title><description><![CDATA[<p>Ich wollte den Hook für das Keyboard aus der FAQ mal testen und habe folgendes programm, welches beim Laden der Funktionen einen Fehler bringt (die DLL kann geladen werden)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef BOOL (*DLLPrcInst) (HWND);
typedef BOOL (*DLLPrcRem) (void);

int APIENTRY WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
{ 
	HMODULE myLib = NULL;
	DLLPrcInst SetHook = NULL;
	DLLPrcRem  RemHook = NULL;

	myLib = LoadLibrary (&quot;KeyboardHook.dll&quot;);

	if (myLib == NULL)
		MessageBox (NULL, &quot;Fehler beim Laden der DLL&quot;, &quot;Error&quot;, MB_OK);

	SetHook = (DLLPrcInst)GetProcAddress (myLib, &quot;_SetupHook&quot;);
	RemHook = (DLLPrcRem)GetProcAddress (myLib, &quot;_UninstallHook&quot;);

	if (SetHook == NULL || RemHook == NULL)
		MessageBox (NULL, &quot;Fehler beim Laden der Funktionen&quot;, &quot;Error&quot;, MB_OK);

	FreeLibrary (myLib);

	return 0;
}
</code></pre>
<p>Was mach ich da, denn falsch?</p>
<p>Edit:</p>
<p>Wie kann ich aus dem Scancode der gedrückten Taste das Zeichen auslesen? Da musste man doch was mit dem &amp;-Operator machen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/85657/fehler-beim-laden-von-dll-funktionen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 02:47:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/85657.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 11 Sep 2004 14:17:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 14:29:15 GMT]]></title><description><![CDATA[<p>Ich wollte den Hook für das Keyboard aus der FAQ mal testen und habe folgendes programm, welches beim Laden der Funktionen einen Fehler bringt (die DLL kann geladen werden)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef BOOL (*DLLPrcInst) (HWND);
typedef BOOL (*DLLPrcRem) (void);

int APIENTRY WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
{ 
	HMODULE myLib = NULL;
	DLLPrcInst SetHook = NULL;
	DLLPrcRem  RemHook = NULL;

	myLib = LoadLibrary (&quot;KeyboardHook.dll&quot;);

	if (myLib == NULL)
		MessageBox (NULL, &quot;Fehler beim Laden der DLL&quot;, &quot;Error&quot;, MB_OK);

	SetHook = (DLLPrcInst)GetProcAddress (myLib, &quot;_SetupHook&quot;);
	RemHook = (DLLPrcRem)GetProcAddress (myLib, &quot;_UninstallHook&quot;);

	if (SetHook == NULL || RemHook == NULL)
		MessageBox (NULL, &quot;Fehler beim Laden der Funktionen&quot;, &quot;Error&quot;, MB_OK);

	FreeLibrary (myLib);

	return 0;
}
</code></pre>
<p>Was mach ich da, denn falsch?</p>
<p>Edit:</p>
<p>Wie kann ich aus dem Scancode der gedrückten Taste das Zeichen auslesen? Da musste man doch was mit dem &amp;-Operator machen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/604615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604615</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sat, 11 Sep 2004 14:29:15 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 18:05:40 GMT]]></title><description><![CDATA[<p>Werden die Funktionen auch genau so exportiert, wie du sie angegeben hast?! Einfach mal mit Dependency Walker nachschauen.</p>
<p>Zum Scancode: evtl. ToAscii - oder von welcher Funktion stammt dein Scancode (denn dort steht doch eigentlich meistens, wie du dann an die einzelnen Infos rankommst) <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/604747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604747</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 11 Sep 2004 18:05:40 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 18:07:56 GMT]]></title><description><![CDATA[<p>So werden sie exportiert</p>
<pre><code class="language-cpp">EXPORT BOOL CALLBACK SetupHook (HWND) ;
EXPORT BOOL CALLBACK UninstallHook (void) ;
</code></pre>
<p>Auch wenn ich den führenden Unterstrich weglasse geht es nicht.</p>
<pre><code class="language-cpp">// Überprüfen ab vor dem Aufruf dieser Funktion die Taste bereits gedrückt war
			SendMessage ((HWND) hWindow, (WM_USER + 2), (WPARAM) wParam, (LPARAM) lParam) ;
			// Senden der Nachricht (WM_USER + 2) und den Tastencode der gedrückten
			// Taste (gespeichert in &quot;wParam&quot;) an das in der globalen Variable
			// hWindow gespeicherte Fensterhandle.
</code></pre>
<p>Also nen normaler Windows Scancode den man bekommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/604748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604748</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sat, 11 Sep 2004 18:07:56 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 18:53:18 GMT]]></title><description><![CDATA[<p>Ich hab das ganze jetzt zum laufen gebracht, allerdings läuft es nur so lange wie in meinem switch in der Nachrichtenprozedur kein case WM_DESTROY steht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Entfernt man das case WM_DESTROY funktioniert es einwandfrei, aber lässt man es so wie unten im Code, dann erhält man beim ersten Tastendruck eine MessageBox und wenn man dort auf ok klickt schließt sich diese und dazu das gesamte Programm <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef BOOL (*DLLPrcInst) (HWND);
typedef BOOL (*DLLPrcRem) (void);

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
{ 
	//
	static TCHAR szAppName[] = TEXT (&quot;KeyLogger&quot;); 
	MSG          msg; 
	HWND hwnd;
	WNDCLASSEX   wndclassex = {0}; 

	wndclassex.cbSize        = sizeof(WNDCLASSEX); 
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW; 
	wndclassex.lpfnWndProc   = WndProc; 
	wndclassex.cbClsExtra    = 0; 
	wndclassex.cbWndExtra    = 0; 
	wndclassex.hInstance     = hinst; 
	wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wndclassex.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); 
	wndclassex.lpszMenuName  = NULL; 
	wndclassex.lpszClassName = szAppName; 
	wndclassex.hIconSm       = wndclassex.hIcon; 

	if (!RegisterClassEx (&amp;wndclassex)) 
	{ 
		MessageBox (NULL, TEXT (&quot;RegisterClassEx fehlgeschlagen!&quot;), szAppName, MB_ICONERROR); 
		return 0; 
	}

	hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil 
		szAppName, // Name der Fensterklasse 
		szAppName, // Fenstertitel 
		WS_OVERLAPPEDWINDOW, // Fensterstil 
		350, // X-Position des Fensters .... CW_USEDEFAULT für Default                      
		300, // Y-Position des Fensters        
		0, // Fensterbreite                  
		0, // Fensterhöhe                 
		NULL, // übergeordnetes Fenster 
		NULL, // Menü            
		hinst, // Programm-Kopiezähler (Programm-ID)             
		NULL); // zusätzliche Parameter 

	ShowWindow (hwnd, SW_MINIMIZE); 
	UpdateWindow (hwnd); 

	/////////////////////////////////////////////////////////////////////////////////
    //					DLL Variablen &amp; Laden der DLL							   //
	/////////////////////////////////////////////////////////////////////////////////
	HMODULE myLib = NULL;
	DLLPrcInst SetHook = NULL;
	DLLPrcRem  RemHook = NULL;

	myLib = LoadLibrary (&quot;KeyboardHook.dll&quot;);

	if (myLib == NULL)
	{
		MessageBox (NULL, &quot;Fehler beim Laden der DLL&quot;, &quot;Error&quot;, MB_OK);
		return 0;
	}

	SetHook = (DLLPrcInst)GetProcAddress (myLib, &quot;SetupHook&quot;);
	RemHook = (DLLPrcRem)GetProcAddress (myLib, &quot;UninstallHook&quot;);

	if (SetHook == NULL || RemHook == NULL)
	{
		MessageBox (NULL, &quot;Fehler beim Laden der Funktionen&quot;, &quot;Error&quot;, MB_OK);
		return 0;
	}

	SetHook (hwnd);	

	//Nachrichtenschleife
	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	} 

	RemHook ();
	FreeLibrary (myLib);

	return 0;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
		case WM_USER+2:
		{
			char str = (char)LOWORD (wparam);
			char stri[2];
			stri[0] = str;
			stri[1] = '\0';
			MessageBox (0, stri, &quot;Info&quot;, MB_OK);
		}
		case WM_DESTROY:
			PostQuitMessage (0);
			return 0;
	}

	return DefWindowProc (hwnd, msg, wparam, lparam); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/604756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604756</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sat, 11 Sep 2004 18:53:18 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 19:30:00 GMT]]></title><description><![CDATA[<p>Dir fehlt im Zweig WM_USER+2 (sowas definiert man sich normalerweise mit einer Konstante, z. b. so: #define WM_MEINEMESSAGE WM_USER+2) auch ein return 0;</p>
<p>Was Du da vorhast (das ausgeben des unteren Wertes von wParam zum char gecastet in einer MessageBox) geht zwar dennoch in die Hose, aber sonst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/604793</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604793</guid><dc:creator><![CDATA[Hepi]]></dc:creator><pubDate>Sat, 11 Sep 2004 19:30:00 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sat, 11 Sep 2004 21:16:33 GMT]]></title><description><![CDATA[<p>MapVirtualKey könnte dir auch behilflich sein <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/604870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/604870</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 11 Sep 2004 21:16:33 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 11:22:59 GMT]]></title><description><![CDATA[<p>Also die Buchstaben gibt er so aus, hatte anfangs nicht mehr dran gedacht, dass ich das Programm ja irgendwie schließen können muss <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>Danke, dann bau ich das return 0 ein und schau mich mal nach MapVirtualKey um</p>
]]></description><link>https://www.c-plusplus.net/forum/post/605073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605073</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sun, 12 Sep 2004 11:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 12:03:21 GMT]]></title><description><![CDATA[<p>Mit MapVirtualKey funktioniert es einwandfrei <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Nur würd ich auch gerne die Alternativbelegungen(strg und altr gr), groß- und kleinbuchstaben haben.<br />
Wie kann ich das machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/605109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605109</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sun, 12 Sep 2004 12:03:21 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 12:36:44 GMT]]></title><description><![CDATA[<p>Evtl. brauchst du dann doch wieder <a href="http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp" rel="nofollow">ToAscii</a> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/605138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605138</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 12 Sep 2004 12:36:44 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 12:42:39 GMT]]></title><description><![CDATA[<p>Würdest du (oder jdm anders) mir nen kleines Beispiel schreiben? Wenn ich das richtig verstehe setzt die Funktion in einem Array mit 256 Einträgen je nachdem welche Taste gedrückt wird ein Bit, aber wie les ich das dann aus und muss ich nach jedem Tastendruck das Array wieder leeren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/605144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605144</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sun, 12 Sep 2004 12:42:39 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 14:20:18 GMT]]></title><description><![CDATA[<p>SirLant schrieb:</p>
<blockquote>
<p>Würdest du (oder jdm anders) mir nen kleines Beispiel schreiben?</p>
</blockquote>
<p>Ich bin gerade zu faul dazu <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>SirLant schrieb:</p>
<blockquote>
<p>Wenn ich das richtig verstehe setzt die Funktion in einem Array mit 256 Einträgen je nachdem welche Taste gedrückt wird ein Bit, aber wie les ich das dann aus und muss ich nach jedem Tastendruck das Array wieder leeren?</p>
</blockquote>
<p>Nein, wenn du genau schaust, siehst du, dass lpKeyState als [in] markiert ist, das heitßt, dass du den Buffer gefüllt übergeben sollst. Diesen Buffer kannst du dir mit GetKeyboardState füllen lassen und dann an die Funktion übergeben. Das Ergebnis (also das oder die Zeichen) bekommst du dann über lpChar.<br />
Ist alles nur theoretisch angedacht - ich hoffe mal, dass das auch so klappt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/605219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605219</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 12 Sep 2004 14:20:18 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 14:48:37 GMT]]></title><description><![CDATA[<p>Ok das hilft mir schonmal weiter, aber die Ausgabe ist immernoch nicht sauber, wenn ich z.B. HALLO WELT (also groß) schreibe dann steht in meiner Textdatei folgendes</p>
<blockquote>
<p>Ìhallo welt</p>
</blockquote>
<p>Mein Code sieht so aus:</p>
<pre><code class="language-cpp">BYTE buf[256];
WORD p;
GetKeyboardState (&amp;buf[0]);
ToAscii (wparam, MapVirtualKey (wparam, 0), &amp;buf[0], &amp;p, 0);

log &lt;&lt; (char)p;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/605228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605228</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sun, 12 Sep 2004 14:48:37 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 15:05:05 GMT]]></title><description><![CDATA[<p>Versuch es mal mit lParam für den 2. Parameter (uScanCode) <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Also so:</p>
<pre><code class="language-cpp">BYTE buf[256];
WORD p;
GetKeyboardState(buf);
ToAscii(wparam,lparam,buf,&amp;p,0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/605260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605260</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 12 Sep 2004 15:05:05 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim Laden von DLL-Funktionen on Sun, 12 Sep 2004 15:28:16 GMT]]></title><description><![CDATA[<p>Danke jetzt klappt es <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/605290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/605290</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Sun, 12 Sep 2004 15:28:16 GMT</pubDate></item></channel></rss>