<?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[DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot;]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte die Funktion &quot;BlockInput&quot; aus der user32.dll laden. Einmal soll er die Tastatur und die Maus sperren und nach 5 Sekunden wieder entsperren.</p>
<p>Wo liegt der Fehler in meinem Code?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;windows.h&gt;

using namespace std;

int main () {
	string pDLL = &quot;D:\\WINDOWS\\system32\\user32.dll&quot;;
	HMODULE hDLL = LoadLibrary (pDLL.c_str());
	FARPROC lock = GetProcAddress (hDLL,&quot;BlockInput&quot;);
	lock (&quot;TRUE&quot;);
	Sleep (5000);
	lock (&quot;FALSE&quot;);
	FreeLibrary (hDLL);
	return 0;
};
</code></pre>
<p>Ich bekomme folgenden Fehlermeldungen:</p>
<blockquote>
<p>[Error] too many arguments to function</p>
</blockquote>
<p>Wo liegt der Fehler bzw. wie muss die Funktion aussehen?</p>
<p>Danke im Voraus!</p>
<p>MfG</p>
<p>Seikuassi</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317465/dll-funktion-aufrufen-gt-mal-wieder-quot-probleme-quot</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 19:29:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317465.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Jun 2013 18:40:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Sun, 09 Jun 2013 18:40:03 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte die Funktion &quot;BlockInput&quot; aus der user32.dll laden. Einmal soll er die Tastatur und die Maus sperren und nach 5 Sekunden wieder entsperren.</p>
<p>Wo liegt der Fehler in meinem Code?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;windows.h&gt;

using namespace std;

int main () {
	string pDLL = &quot;D:\\WINDOWS\\system32\\user32.dll&quot;;
	HMODULE hDLL = LoadLibrary (pDLL.c_str());
	FARPROC lock = GetProcAddress (hDLL,&quot;BlockInput&quot;);
	lock (&quot;TRUE&quot;);
	Sleep (5000);
	lock (&quot;FALSE&quot;);
	FreeLibrary (hDLL);
	return 0;
};
</code></pre>
<p>Ich bekomme folgenden Fehlermeldungen:</p>
<blockquote>
<p>[Error] too many arguments to function</p>
</blockquote>
<p>Wo liegt der Fehler bzw. wie muss die Funktion aussehen?</p>
<p>Danke im Voraus!</p>
<p>MfG</p>
<p>Seikuassi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329700</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329700</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Sun, 09 Jun 2013 18:40:03 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Wed, 11 Jun 2014 23:33:42 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329703</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:33:42 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Sun, 09 Jun 2013 19:09:44 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<blockquote>
<p>Wie wär's wenn du erst die Sprache lernst, anstatt sinnlos herumzuspielen?</p>
</blockquote>
<p>Das kann man zwar als herumspielen bezeichnen, aber wie du siehst, möchte ich eigentlich nur wissen, wie man eine Funktion aus einer DLL aufrufen (callen) kann.<br />
Bei AutoIT konnte ich den Befehl DLLCall benutzen. Und wie mache ich das jetzt in C++? BlockInput soll nur ein Beispiel sein. Mir fiel aus dem Kopf spontan keine andere Funktion ein, die man Parameter übergeben kann.</p>
<p>Warum geht jetzt nicht mein Code? GetProcAddress liefert mir ja den Datentyp <em>FARPROC</em> zurück. Wie soll ich dann einen <em>BOOL</em> übergeben?</p>
<p>Danke im Voraus!</p>
<p>MfG</p>
<p>Ph. Buchmann</p>
<p>P.S.: Ich denke übrigens, dass die meisten von und (natürlich nicht nur) durch &quot;herumspielen&quot; die Sprache gelernt haben. Denn durch praktisches &quot;Herumspielen&quot; lernt man (so ist es jedenfalls bei mir <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/2329705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329705</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Sun, 09 Jun 2013 19:09:44 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Wed, 11 Jun 2014 23:33:46 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329712</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:33:46 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Mon, 10 Jun 2013 06:43:21 GMT]]></title><description><![CDATA[<p>@Seikuassi:<br />
Kann es sein dass du dich ein wenig mit Hacking beschätigen willst, oder warum willst du die DLL Funkion auf eine solchen Art und Weise aufrufen? Warum nicht sicherstellen dass die richtige Lib und Header Datei eingebunden ist und die Funktion einfach so aufrufen?</p>
<p>Wenn du die Funktion unbedingt per GetProcAddress aufrufen willst, dann schaue dir mal das Beispiel zu <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx" rel="nofollow">GetProcAddress</a> an. Und schaue dir auch mal den Unterschied zwischen LoadLibrary und GetModuleHandle an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329790</guid><dc:creator><![CDATA[Bitte ein Bit]]></dc:creator><pubDate>Mon, 10 Jun 2013 06:43:21 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Mon, 10 Jun 2013 11:12:20 GMT]]></title><description><![CDATA[<p>@Seikuassi :<br />
Mal ne dumme Frage:</p>
<p>Was hat es mit deinem Doppelpost <a href="http://www.c-plusplus.net/forum/p2329183#2329183" rel="nofollow">Anfängerfrage DLL</a> auf sich? Warum hast du einen neuen Thread aufgemacht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329889</guid><dc:creator><![CDATA[Bitte ein Bit]]></dc:creator><pubDate>Mon, 10 Jun 2013 11:12:20 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Mon, 10 Jun 2013 12:23:02 GMT]]></title><description><![CDATA[<p>Dieses Beispiel ist nicht sehr sinnvoll.<br />
Auf Windows Rechnern kann bzw. muss man davon ausgehen, dass User32.dll vorhanden ist und kann die Funktionen statisch linken.</p>
<p>LoadLibrary ist nur dann sinnvoll, wenn man beim nicht vorhanden sein einer DLL entsprechend reagieren will, also nicht mit einer Standardmessagebox oder man dynamisch Funktionen daraus laden will, z.B. weil man DLLs als Plugins hinzugefügen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2329915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2329915</guid><dc:creator><![CDATA[Marthog]]></dc:creator><pubDate>Mon, 10 Jun 2013 12:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Thu, 13 Jun 2013 13:09:37 GMT]]></title><description><![CDATA[<blockquote>
<p>Was hat es mit deinem Doppelpost Anfängerfrage DLL auf sich? Warum hast du einen neuen Thread aufgemacht?</p>
</blockquote>
<p>Ups... <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>
<blockquote>
<p>@Seikuassi:<br />
Kann es sein dass du dich ein wenig mit Hacking beschätigen willst [...]</p>
</blockquote>
<p>Ich bin noch ein blutiger Anfänger! Was soll ich da mit Hacking zu tun haben? Ich will nur gucken, wie man eine DLL dynamisch aufruft.</p>
<blockquote>
<p>Seikuassi schrieb:<br />
Denn durch praktisches &quot;Herumspielen&quot; lernt man (so ist es jedenfalls bei mir <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>Das denken erstaunlich viele. Ob's effizient ist, grad' bei C++, ist halt die andere Frage.</p>
</blockquote>
<p>Ich möchte zwar kein Klugscheißer sein, aber ob ich jetzt effizient arebite, ist mir eigentlich Jacke wie Hose. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Letzte Frage: Warum funktioniert der folgende Code nicht?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;

template &lt;typename T0,typename T1&gt;
T0 DLL_Call (string pDLL,string function,T1 parameter) {
	typedef int (__cdecl *MYPROC)(T1);
	HMODULE hDLL;
	MYPROC ProcAdd;
	hDLL = LoadLibrary (pDLL.c_str());
	ProcAdd = (MYPROC) /* &lt;-- */ GetProcAddress (hDLL,function.c_str());
	(ProcAdd) (parameter);
	FreeLibrary (hDLL);
	T0 result = (ProcAdd);
	return result;
};
int main() {
	DLL_Call (&quot;D:\\WINDOWS\\system32\\kernel32.dll&quot;,&quot;Sleep&quot;,2000);
	cout &lt;&lt; &quot;[Beenden]&quot;;
	system (&quot;pause &gt; NUL&quot;);
	return 0;
};
</code></pre>
<p>Ich bekomme folgende Fehlermedlungen (zur Erinnerung: ich benutze Dev-C++):</p>
<blockquote>
<p>16 62 D:\Dokumente und Einstellungen\Philipp Buchmann\Desktop\main.cpp [Error] no matching function for call to 'DLL_Call(const char [33], const char [6], int)'<br />
16 62 D:\Dokumente und Einstellungen\Philipp Buchmann\Desktop\main.cpp [Note] candidate is:<br />
4 4 D:\Dokumente und Einstellungen\Philipp Buchmann\Desktop\main.cpp [Note] template&lt;class T0, class T1&gt; T0 DLL_Call(std::string, std::string, T1)<br />
4 4 D:\Dokumente und Einstellungen\Philipp Buchmann\Desktop\main.cpp [Note] template argument deduction/substitution failed:<br />
16 62 D:\Dokumente und Einstellungen\Philipp Buchmann\Desktop\main.cpp [Note] couldn't deduce template parameter 'T0'</p>
</blockquote>
<p>Danke im Voraus!</p>
<p>MfG</p>
<p>Ph. Buchmann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330786</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Thu, 13 Jun 2013 13:09:37 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Wed, 11 Jun 2014 23:33:51 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330787</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:33:51 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Thu, 13 Jun 2013 13:29:34 GMT]]></title><description><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms686944(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ms686944(v=vs.85).aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330788</guid><dc:creator><![CDATA[MSDN]]></dc:creator><pubDate>Thu, 13 Jun 2013 13:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Thu, 13 Jun 2013 14:10:06 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe jetzt die Lösung. Ich verwende einfach nur ein Template und gebe als Rückgabewert immer einen string:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;sstream&gt;
#include &lt;windows.h&gt;

using namespace std;

template &lt;typename T&gt;
string DLL_Call (string pDLL,string function,T parameter) {
	typedef int (__cdecl *MYPROC)(T);
	HMODULE hDLL;
	MYPROC ProcAdd;
	hDLL = LoadLibrary (pDLL.c_str());
	ProcAdd = (MYPROC) /* &lt;-- */ GetProcAddress (hDLL,function.c_str());
	(ProcAdd) (parameter);
	FreeLibrary (hDLL);
	string result_0;
	stringstream result_1;
	result_1 &lt;&lt; (ProcAdd);
	result_1 &gt;&gt; result_0;
	return result_0;
};
int main() {
	string x = DLL_Call (&quot;D:\\WINDOWS\\system32\\kernel32.dll&quot;,&quot;Sleep&quot;,2500);
	cout &lt;&lt; x.c_str() &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; &quot;[Beenden]&quot;;
	system (&quot;pause &gt; NUL&quot;);
	return 0;
};
</code></pre>
<p>Danke für eure Hilfe!</p>
<p>MfG</p>
<p>Ph. Buchmann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330796</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330796</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Thu, 13 Jun 2013 14:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Wed, 11 Jun 2014 23:33:55 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330803</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:33:55 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Thu, 13 Jun 2013 14:56:50 GMT]]></title><description><![CDATA[<p>Hallo Swordfish,</p>
<blockquote>
<p>Tut nicht, was du glaubst.</p>
</blockquote>
<p>Stimmt. Aber wenn Sleep mir ein void zurückgibt, warum bekomme ich dann eine 1 zurück?</p>
<p>Und noch eine Frage: Hier<br />
[url]<br />
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms686923%28v=vs.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ms686923(v=vs.85).aspx</a><br />
[/url]<br />
wird ja die Verknüpfung mit einer DLL während der &quot;Ladezeit&quot; beschrieben. Wo kann ich denn jetzt da einen absoluten Pfad einsetzen?</p>
<blockquote>
<p><strong>irgendeiner wird schreiben:</strong><br />
Und warum willst du das tun?</p>
</blockquote>
<p>Ich will es nur wissen.</p>
<p>Danke im Voraus!</p>
<p>MfG</p>
<p>Ph. Buchmann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330809</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Thu, 13 Jun 2013 14:56:50 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Thu, 13 Jun 2013 16:30:12 GMT]]></title><description><![CDATA[<blockquote>
<p>Wo kann ich denn jetzt da einen absoluten Pfad einsetzen?</p>
</blockquote>
<p>Okay, Frage hat sich erledigt. Die DLL muss gelinkt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330843</guid><dc:creator><![CDATA[Seikuassi]]></dc:creator><pubDate>Thu, 13 Jun 2013 16:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Funktion aufrufen --&amp;gt; mal wieder &amp;quot;Probleme&amp;quot; on Wed, 11 Jun 2014 23:33:59 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2330852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2330852</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 11 Jun 2014 23:33:59 GMT</pubDate></item></channel></rss>