<?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[Funktion aus DLL ausführen]]></title><description><![CDATA[<p>Hi, ich habe eine Frage zu DLLs. Wie kann man eine exportierte Funktion ausführen. Angenommen ich habe die Funktion Hallo() exportiert. Jetzt finde ich mit Hilfe von DEPENDS den Namen der Funktion in der DLL:<br />
&quot;?Hallo@@YAXXZ&quot;. Ich habe mir ein kleines prog zusammengestellt, das die datei sucht und die funktion sucht. Wenn ich das Programm starte, erhalte ich Info, dass das Prog. sowohl die DLL als auch die Funktion findet. Weiss Jemand, wie ich die Funktion nun ausführe ?</p>
<p>Hier der Code des Progs. DLLstart.cpp</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;iostream&gt;

using namespace std;

HINSTANCE LoadMe;

int main()
{
	LoadMe = LoadLibrary(&quot;DLL.dll&quot;);

if (LoadMe != 0)
    cout&lt;&lt;&quot;DLL geladen\n&quot;&lt;&lt;endl;
else
    cout&lt;&lt;&quot;DLL nicht geladen\n&quot;&lt;&lt;endl;

if (!GetProcAddress(LoadMe,&quot;?Hallo@@YAXXZ&quot;))
  cout&lt;&lt;&quot;Funktion nicht da\n&quot;&lt;&lt;endl;

else cout&lt;&lt;&quot;Funktion gefunden\n&quot;&lt;&lt;endl;

system(&quot;PAUSE&quot;);
return 0;
}[
</code></pre>
<p>Ich brauche wirklich dringend Hilfe. In anderen Foren konnte mir bislang Niemand helfen.Ich will die Funktion Hallo() einfach ausgeführt bekommen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/98248/funktion-aus-dll-ausführen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 15:21:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/98248.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Jan 2005 08:43:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 08:43:32 GMT]]></title><description><![CDATA[<p>Hi, ich habe eine Frage zu DLLs. Wie kann man eine exportierte Funktion ausführen. Angenommen ich habe die Funktion Hallo() exportiert. Jetzt finde ich mit Hilfe von DEPENDS den Namen der Funktion in der DLL:<br />
&quot;?Hallo@@YAXXZ&quot;. Ich habe mir ein kleines prog zusammengestellt, das die datei sucht und die funktion sucht. Wenn ich das Programm starte, erhalte ich Info, dass das Prog. sowohl die DLL als auch die Funktion findet. Weiss Jemand, wie ich die Funktion nun ausführe ?</p>
<p>Hier der Code des Progs. DLLstart.cpp</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;iostream&gt;

using namespace std;

HINSTANCE LoadMe;

int main()
{
	LoadMe = LoadLibrary(&quot;DLL.dll&quot;);

if (LoadMe != 0)
    cout&lt;&lt;&quot;DLL geladen\n&quot;&lt;&lt;endl;
else
    cout&lt;&lt;&quot;DLL nicht geladen\n&quot;&lt;&lt;endl;

if (!GetProcAddress(LoadMe,&quot;?Hallo@@YAXXZ&quot;))
  cout&lt;&lt;&quot;Funktion nicht da\n&quot;&lt;&lt;endl;

else cout&lt;&lt;&quot;Funktion gefunden\n&quot;&lt;&lt;endl;

system(&quot;PAUSE&quot;);
return 0;
}[
</code></pre>
<p>Ich brauche wirklich dringend Hilfe. In anderen Foren konnte mir bislang Niemand helfen.Ich will die Funktion Hallo() einfach ausgeführt bekommen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699147</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 08:43:32 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 08:48:15 GMT]]></title><description><![CDATA[<p>GetProcAddress liefert dir einen Funktionszeiger zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699149</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 18 Jan 2005 08:48:15 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 08:53:20 GMT]]></title><description><![CDATA[<p>Compy schrieb:</p>
<blockquote>
<p>Ich brauche wirklich dringend Hilfe. In anderen Foren konnte mir bislang Niemand helfen.Ich will die Funktion Hallo() einfach ausgeführt bekommen</p>
</blockquote>
<p>Muss man dazu nicht wenigstens die Deklaration der Funktion kennen? Schlagt mich, wenn ich mich täusche. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>zwette</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699152</guid><dc:creator><![CDATA[zwette]]></dc:creator><pubDate>Tue, 18 Jan 2005 08:53:20 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 09:02:38 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>die Funktion Hallo()</p>
<p>DLL.cpp</p>
<pre><code>#include &quot;DLL.h&quot;

#pragma once

#define WIN32_LEAN_AND_MEAN		
#include &lt;windows.h&gt;
#include &lt;iostream&gt;
using namespace std;

DLL_API void Hallo()
{
	cout&lt;&lt;&quot;HALLO&quot;&lt;&lt;endl;
}
</code></pre>
<p>DLL.h</p>
<pre><code>#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

DLL_API void Hallo();
</code></pre>
<p>Reicht dir das so ? <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="🙂"
    /><br />
Das sind Teile der Header und CPP-Dateien der DLL. Wie kann ich es machen, dass ich die Funktion Hallo() aus der DLL ausführe (also, dass &quot;Hallo&quot; erscheint) ?</p>
<p>MFK, und wie kann ich es nun ausführen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699157</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 09:02:38 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 09:46:40 GMT]]></title><description><![CDATA[<p>ok, da hier niemand antwortet, denke ich, ihr wisst selbst leider net, wie man es lösen könnte.<br />
Könnt ihr mir dann ein Programm und eine DLL schreiben ?<br />
Die DLL soll die Funktion HalloWelt()beinhalten und exportieren. Das Programm soll auf die Funktion zugreifen und es soll am Bildschirm &quot;Hallo&quot; erscheinen. Nur damit ich es kapiere <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="🙂"
    /> Ich benutze Microsoft´s Visual <a href="http://C++.NET" rel="nofollow">C++.NET</a><br />
Bitte schreibt Jamend kurz so ein Prog ? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/699192</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699192</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 09:46:40 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 09:55:17 GMT]]></title><description><![CDATA[<p>Compy schrieb:</p>
<blockquote>
<p>MFK, und wie kann ich es nun ausführen ?</p>
</blockquote>
<p>Du musst den Funktionszeiger zuerst auf den richtigen Typ für deine Funktion casten. Danach rufst du deine Funktion über den Funktionszeiger auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699195</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 18 Jan 2005 09:55:17 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:00:07 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ähmm...Beispiel ? Wie mach ich das ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699200</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:04:19 GMT]]></title><description><![CDATA[<p>Versuch mal die Suchfunktion:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=96872&amp;highlight=getprocaddress" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=96872&amp;highlight=getprocaddress</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/699205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699205</guid><dc:creator><![CDATA[suchemal]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:04:19 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:06:57 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/699207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699207</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:09:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// dll funktion
void Hallo(void);

// in deinem proggie
void (dll_func*)(void);  // Funktionszeiger

// aufruffunktion fuer dll_funktion(void Hallo(void);
void RufMitHalloFunktionInDllAuf(void)
{
   HINSTANCE handle = LoadLibrary(&quot;meineHelloDll.dll&quot;);
   FARPROC fp = GetProcessAddress(handle,&quot;Hallo&quot;);
   dll_func = (void(*)(void))fp;
   (*dll_func)();
   FreeLibrary(handle);
}
</code></pre>
<p>ich hoff ich hab da mal keinen fehler drinnen</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699211</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:09:44 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:28:05 GMT]]></title><description><![CDATA[<p>Hi, danke für die Hilfe. Hab mich nun umgeschaut bei Microsoft.<br />
Und habe meinen Code geändert:</p>
<pre><code>#include &lt;stdio.h&gt; 
#include &lt;windows.h&gt; 

typedef UINT (CALLBACK* LPFNDLLFUNC1)(DWORD,UINT);

HINSTANCE hDLL;               // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1;    // Function pointer
DWORD dwParam1;
UINT  uParam2, uReturnVal;

int main()
{
hDLL = LoadLibrary(&quot;DLL.dll&quot;);
if (hDLL != NULL)
{
   lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,
                                           &quot;?Hallo@@YAXXZ&quot;);
   if (!lpfnDllFunc1)
   {
      // handle the error
      FreeLibrary(hDLL);

      return 0;
   }
   else
   {
      // call the function
      uReturnVal = lpfnDllFunc1(dwParam1,uParam2);
   }
}
system(&quot;PAUSE&quot;);
return 0;
}
</code></pre>
<p>Jetzt kommt aber noch ein Fehler:</p>
<p>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</p>
<p>Wisst ihr, was ich nun machen soll ? Der Fehler scheint bei &quot;uReturnVal&quot; zu liegen. Ausgabe kommt zwar &quot;Hallo&quot;, aber auch leider dieser Fehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699220</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:28:05 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 10:35:31 GMT]]></title><description><![CDATA[<p>Meep Meep,</p>
<p>Ich habe das nun so im Prog eingetragen :</p>
<pre><code>#include &lt;stdio.h&gt; 
#include &lt;windows.h&gt; 

void (dll_func*)(void);

void lol(void) 
{ 
   HINSTANCE handle = LoadLibrary(&quot;DLL.dll&quot;); 
   FARPROC fp = GetProcAddress(handle,&quot;Hallo&quot;); 
   dll_func = (void(*)(void))fp; 
   (*dll_func)(); 
   FreeLibrary(handle); 
} 
int main()
{
	lol();
	system(&quot;PAUSE&quot;);
	return 0;
}
</code></pre>
<p>Fehler:</p>
<p>...\Dllstarten\Dllstarten.cpp(10): error C2065: 'dll_func' : nichtdeklarierter Bezeichner<br />
...\Dllstarten\Dllstarten.cpp(11): error C2100: Zeigeroperation ungültig<br />
...\Dllstarten\Dllstarten.cpp(4): error C2629: 'void (' unerwartet</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699223</guid><dc:creator><![CDATA[Compy]]></dc:creator><pubDate>Tue, 18 Jan 2005 10:35:31 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 11:58:54 GMT]]></title><description><![CDATA[<p>Hier mal ein einfaches Beispiel</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
typedef void (*hallo_func_ptr)(void);

int main()
{
    HMODULE h_dll = LoadLibrary(_T(&quot;meine_dll.dll&quot;));
    if (!h_dll)
        return whatever;
    hallo_func_ptr hallo_func = (hallo_func_ptr) GetProcAddress(h_dll, _T(&quot;hallo&quot;));
    if (!hallo_func)
        // error
    else
    {
        // Funktion kann jetzt aufgerufen werden
        hallo_func();
        //...
    }
    FreeLibrary(h_lib);
    return 0;
}
// ungetestet
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/699273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699273</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Tue, 18 Jan 2005 11:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion aus DLL ausführen on Tue, 18 Jan 2005 11:55:43 GMT]]></title><description><![CDATA[<blockquote>
<p>This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</p>
</blockquote>
<p>Das sagt eh schon alles. Du solltest außerdem mal extern &quot;C&quot; verwenden, damit du nicht diesen komplizierten Funktionsnamen nachschauen musst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/699274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/699274</guid><dc:creator><![CDATA[Ringding]]></dc:creator><pubDate>Tue, 18 Jan 2005 11:55:43 GMT</pubDate></item></channel></rss>