<?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[einfach eine funktion einer DLL aufrufen]]></title><description><![CDATA[<p>*sorry wieder eine warscheinlich sau simple frage *</p>
<p>Ich habe nur so halb Tutorials dazu gefunden, und mir was zusammengesückelt,<br />
aber es funktioniert irgendwie nicht</p>
<p>Application</p>
<pre><code>//mainapp.cpp
#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;string&gt;

typedef std::string (WINAPI PLUGM)
(
 std::string bef
);
typedef PLUGM *LPPLUG;
using namespace std;
int main ()
{
   HINSTANCE hinstDLL;
   LPPLUG myPlug;
   if (NULL == (hinstDLL = LoadLibrary (&quot;sample.dll&quot;)))
   {
      cout&lt;&lt; &quot;Die DLL konnte nicht geladen werden!&quot;&lt;&lt; endl;
      return 0;
   }
   myPlug = (LPPLUG) GetProcAddress (hinstDLL, &quot;PLUGM&quot;);

   if (myPlug == NULL)
   {
      cout &lt;&lt; &quot;Die Funktion existiert nicht in der DLL!&quot;&lt;&lt; endl;
      return 0;
   }

   std::cout &lt;&lt; myPlug (&quot;lol&quot;);
   FreeLibrary (hinstDLL);
   return 0;
}
</code></pre>
<p>Dll</p>
<pre><code>//dllmain.cpp

#include &lt;windows.h&gt;

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT
#endif

#include &lt;string&gt;
// a sample exported function
std::string DLL_EXPORT PLUGM(const LPCSTR sometext)
{
    return &quot;DLL Message&quot;;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // succesful
}
</code></pre>
<p>kann mir jemand helfen?</p>
<p>was ist bloß falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145586/einfach-eine-funktion-einer-dll-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 14:12:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145586.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Apr 2006 12:27:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 12:28:43 GMT]]></title><description><![CDATA[<p>*sorry wieder eine warscheinlich sau simple frage *</p>
<p>Ich habe nur so halb Tutorials dazu gefunden, und mir was zusammengesückelt,<br />
aber es funktioniert irgendwie nicht</p>
<p>Application</p>
<pre><code>//mainapp.cpp
#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;string&gt;

typedef std::string (WINAPI PLUGM)
(
 std::string bef
);
typedef PLUGM *LPPLUG;
using namespace std;
int main ()
{
   HINSTANCE hinstDLL;
   LPPLUG myPlug;
   if (NULL == (hinstDLL = LoadLibrary (&quot;sample.dll&quot;)))
   {
      cout&lt;&lt; &quot;Die DLL konnte nicht geladen werden!&quot;&lt;&lt; endl;
      return 0;
   }
   myPlug = (LPPLUG) GetProcAddress (hinstDLL, &quot;PLUGM&quot;);

   if (myPlug == NULL)
   {
      cout &lt;&lt; &quot;Die Funktion existiert nicht in der DLL!&quot;&lt;&lt; endl;
      return 0;
   }

   std::cout &lt;&lt; myPlug (&quot;lol&quot;);
   FreeLibrary (hinstDLL);
   return 0;
}
</code></pre>
<p>Dll</p>
<pre><code>//dllmain.cpp

#include &lt;windows.h&gt;

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT
#endif

#include &lt;string&gt;
// a sample exported function
std::string DLL_EXPORT PLUGM(const LPCSTR sometext)
{
    return &quot;DLL Message&quot;;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // succesful
}
</code></pre>
<p>kann mir jemand helfen?</p>
<p>was ist bloß falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047666</guid><dc:creator><![CDATA[download123]]></dc:creator><pubDate>Sat, 29 Apr 2006 12:28:43 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 12:44:35 GMT]]></title><description><![CDATA[<p>Du mußt schon selber dafür sorgen, daß du den richtigen Funktionstyp verwendest. Deine DLL-Funktion erwartet einen &quot;const LPCSTR&quot; Parameter, über den Funktionspointer übergibst du ihr aber einen &quot;std::string&quot; - da ist es unausweichlich, daß du dein Programm in Stücke schießt.</p>
<p>(und da der Compiler kann dich nichtmal davor warnen, daß du etwas falsch machst)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047698</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 29 Apr 2006 12:44:35 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 12:59:08 GMT]]></title><description><![CDATA[<p>hups....</p>
<p>gut, berichtigt, geht aber trotzdem nicht</p>
<p>DLL Code</p>
<pre><code>#include &lt;windows.h&gt;

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT
#endif

#include &lt;string&gt;
// a sample exported function
std::string DLL_EXPORT PLUGM(std::string bef)
{
    return &quot;DLL Message&quot;;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // succesful
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1047711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047711</guid><dc:creator><![CDATA[download123]]></dc:creator><pubDate>Sat, 29 Apr 2006 12:59:08 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 14:23:58 GMT]]></title><description><![CDATA[<p>Hast du die Funktion auch als Symbol definiert?<br />
In dem Projekt mus irgendwo Export.def sein, da musst du den Funktionsnamen noch hinzufügen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047782</guid><dc:creator><![CDATA[qasdfgh]]></dc:creator><pubDate>Sat, 29 Apr 2006 14:23:58 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 15:04:08 GMT]]></title><description><![CDATA[<p>Kriegst du überhaupt die Addresse der Funktion so wie du GetProcAddress aufrufst? Vermutlich wird sie unter einem anderen Namen exportiert (Name Mangling)...schau sonst mal mit Dependency Walker nach. Ausserdem könnte es auch ein Problem sein wenn die Dll und Exe unterschiedliche Versionen der C Laufzeitbibliothek benutzen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047811</guid><dc:creator><![CDATA[WebNubbi]]></dc:creator><pubDate>Sat, 29 Apr 2006 15:04:08 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 16:07:35 GMT]]></title><description><![CDATA[<p>Was geht denn nicht?<br />
Und es könnte nicht nur sein, dass es Probleme gibt, wenn die EXE und die DLL unterschiedliche CRTs verwenden, sondern dies gibt 100%ig Probleme.<br />
Also: EXE und DLL müssen die gleiche CRT-DLL-Version verwenden!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047874</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 29 Apr 2006 16:07:35 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 16:55:41 GMT]]></title><description><![CDATA[<p>also das problem ist das das programm ausgibt das die funktion nicht gefunden wurde....</p>
<p>ich raf net was ich falsch gemacht habe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047899</guid><dc:creator><![CDATA[download123]]></dc:creator><pubDate>Sat, 29 Apr 2006 16:55:41 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 19:35:13 GMT]]></title><description><![CDATA[<p>Ach so... du verwendest &quot;GetProcAddress&quot;... hab ich übersehen... der Namen ist einfach falsch.<br />
Schau Dir mal den Namen der Methode in der DLL z.B. mit depends an...<br />
<a href="http://www.dependencywalker.com/" rel="nofollow">http://www.dependencywalker.com/</a></p>
<p>Und wie gesagt: Du musst wirklich die <strong>gleiche</strong>DLL-Version der CRT in der EXE und der DLL verwenden, wenn Du STL/MFC/CRT Klassen in der Funktions-Signatur verwendest!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1047982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1047982</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 29 Apr 2006 19:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to einfach eine funktion einer DLL aufrufen on Sat, 29 Apr 2006 20:48:26 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;string&gt;

typedef std::string (__stdcall*_plugm)(std::string);
_plugm PLUGM = NULL;

int main(void)
{
    // Library laden
    ::HINSTANCE__* hDll = ::LoadLibrary (&quot;sample.dll&quot;);

    if(hDll == NULL) 
    {
        std::cout &lt;&lt; &quot;Die gewünschte Datei konnte nicht geladen/gefunden werden!&quot; &lt;&lt; std::endl;
        return -1;
    }

    PLUGM = reinterpret_cast&lt;_plugm&gt;(::GetProcAddress(hDll,&quot;PLUGM&quot;));

    if(PLUGM == NULL)
    {
        ::FreeLibrary (dll);
        std::cout &lt;&lt; &quot;Es ist ein Fehler beim Laden aufgetreten!&quot; &lt;&lt; std::endl;
        return -1;
    }

    std::cout &lt;&lt; ::PLUGM(&quot;lol&quot;) &lt;&lt; std::endl;

    ::FreeLibrary(hDll);

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1048014</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048014</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sat, 29 Apr 2006 20:48:26 GMT</pubDate></item></channel></rss>