<?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 einbinden und Funktion aus DLL aufrufen?]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich habe eine DLL folgendermaßen geladen.</p>
<pre><code class="language-cpp">typedef int (*MYPROC)(void);
HINSTANCE hinstLib; 
MYPROC ProcAdd; 
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
...

LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
  switch (message)
  {
    case WM_CREATE:
      hinstLib = LoadLibrary(TEXT(&quot;EINE_DLL.dll&quot;)); 

      // If the handle is valid, try to get the function address. 

      if (hinstLib != NULL) 
      { 
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT(&quot;DLLFunktion&quot;)); 

        // If the function address is valid, call the function. 

        if (NULL != ProcAdd) 
        { 
          fRunTimeLinkSuccess = TRUE; 
        }

        // Free the DLL module. 

      } 

      // If unable to call the DLL function, use an alternative. 

      if (!fRunTimeLinkSuccess)
        MessageBox(hwnd, &quot;&gt;EINE_DLL.dll&lt; konnte nicht geladen werden!&quot;, &quot;Achtung&quot;, MB_ICONWARNING);
      ...
    case WM_COMMAND:
      switch (HIWORD(wParam))
      {
        case BN_CLICKED:
          switch (LOWORD(wParam))
          {
            case but1:
            {
              /*Hier möchte ich die Funktion &quot;DLLFunktion&quot; aus der DLL laden*/
            }
            break;
          }
        break;
      }
      return 0;
    case WM_DESTROY:
      fFreeResult = FreeLibrary(hinstLib);
      if (!fFreeResult)
        MessageBox(0,&quot;&gt;EINE_DLL.dll&lt; konnte nicht freigegeben werden!&quot;,&quot;Achtung&quot;, MB_ICONWARNING);
      ...
</code></pre>
<p>In Zeile 44 liegt mein Problem. Wie kann ich die Funktion aus der DLL aufrufen, wenn diese Funktion z. B. so in der DLL deklariert ist: &quot;double Funktion(double wert1, int wert2)&quot;.</p>
<p>Oder was habe ich falsch gemacht? Ich habe leider noch nicht genug Erfahrung mit DLL's.</p>
<p>Danke im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161290/dll-einbinden-und-funktion-aus-dll-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 09:34:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161290.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Oct 2006 10:03:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 10:03:48 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich habe eine DLL folgendermaßen geladen.</p>
<pre><code class="language-cpp">typedef int (*MYPROC)(void);
HINSTANCE hinstLib; 
MYPROC ProcAdd; 
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
...

LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
  switch (message)
  {
    case WM_CREATE:
      hinstLib = LoadLibrary(TEXT(&quot;EINE_DLL.dll&quot;)); 

      // If the handle is valid, try to get the function address. 

      if (hinstLib != NULL) 
      { 
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT(&quot;DLLFunktion&quot;)); 

        // If the function address is valid, call the function. 

        if (NULL != ProcAdd) 
        { 
          fRunTimeLinkSuccess = TRUE; 
        }

        // Free the DLL module. 

      } 

      // If unable to call the DLL function, use an alternative. 

      if (!fRunTimeLinkSuccess)
        MessageBox(hwnd, &quot;&gt;EINE_DLL.dll&lt; konnte nicht geladen werden!&quot;, &quot;Achtung&quot;, MB_ICONWARNING);
      ...
    case WM_COMMAND:
      switch (HIWORD(wParam))
      {
        case BN_CLICKED:
          switch (LOWORD(wParam))
          {
            case but1:
            {
              /*Hier möchte ich die Funktion &quot;DLLFunktion&quot; aus der DLL laden*/
            }
            break;
          }
        break;
      }
      return 0;
    case WM_DESTROY:
      fFreeResult = FreeLibrary(hinstLib);
      if (!fFreeResult)
        MessageBox(0,&quot;&gt;EINE_DLL.dll&lt; konnte nicht freigegeben werden!&quot;,&quot;Achtung&quot;, MB_ICONWARNING);
      ...
</code></pre>
<p>In Zeile 44 liegt mein Problem. Wie kann ich die Funktion aus der DLL aufrufen, wenn diese Funktion z. B. so in der DLL deklariert ist: &quot;double Funktion(double wert1, int wert2)&quot;.</p>
<p>Oder was habe ich falsch gemacht? Ich habe leider noch nicht genug Erfahrung mit DLL's.</p>
<p>Danke im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149780</guid><dc:creator><![CDATA[Bohr dir&#x27;n Loch ins Knie]]></dc:creator><pubDate>Thu, 05 Oct 2006 10:03:48 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 10:15:40 GMT]]></title><description><![CDATA[<p>Achso, wollte eigentlich einen anderen Benutzernamen verwenden.</p>
<p>Soll keine Beleidigung sein. (Ich find den Spruch nur lustig)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149791</guid><dc:creator><![CDATA[Bohr dir&#x27;n Loch ins Knie]]></dc:creator><pubDate>Thu, 05 Oct 2006 10:15:40 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 11:00:26 GMT]]></title><description><![CDATA[<p>Bohr Dir'n Loch ins Knie schrieb:</p>
<blockquote>
<p>Achso, wollte eigentlich einen anderen Benutzernamen verwenden.</p>
<p>Soll keine Beleidigung sein. (Ich find den Spruch nur lustig)</p>
</blockquote>
<p>Erst denken, dann schreiben. :p</p>
<p>Wenn ich es richtig verstanden habe: Wenn die DLL richtig eingebunden ist, kannst Du die Funktion einfach normal aufrufen wie jede andere Funktion auch. Oder kommt da eine Fehlermeldung? Natürlich mußt Du sie im Header als extern bzw. Import-Funktion deklarieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149820</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Thu, 05 Oct 2006 11:00:26 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 12:00:56 GMT]]></title><description><![CDATA[<p>Bohr dir'n Loch ins Knie schrieb:</p>
<blockquote>
<p>Wie kann ich die Funktion aus der DLL aufrufen, <strong>wenn diese Funktion z. B. so in der DLL deklariert ist: &quot;double Funktion(double wert1, int wert2)&quot;.</strong></p>
</blockquote>
<p><strong>Laden:</strong></p>
<pre><code class="language-cpp">typedef double (__cdecl* PDLLFUNKTION) (double, int); // nicht zwingend aber schöner
HMODULE hmDeineDLL = LoadLibrary(TEXT(&quot;DATEINAME.DLL&quot;)); // implementiert als ANSI und UNICODE
PDLLFUNKTION pDeineFunktion = reinterpret_cast&lt;PDLLFUNKTION&gt;(GetProcAdress(hmDeineDLL, &quot;Funktion&quot;)); // ACHTUNG: nur ANSI
</code></pre>
<p><strong>Aufruf:</strong></p>
<pre><code class="language-cpp">double dResult = pDeineFunktion(12.23, 34.88);
</code></pre>
<p>Allerdings weiß ich (wie Elektronix auch <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="😉"
    /> ) nicht genau, ob du das meinst <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>PS: Fehlerüberprüfungen hab ich mir mal gescheckt, sollte man aber machen.</p>
<p>EDIT: Siehe unten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149829</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 12:00:56 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 11:44:09 GMT]]></title><description><![CDATA[<p>von GetProcAddress gibt es keine Unicode-Variante. Das TEXT ist dort falsch. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1149850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149850</guid><dc:creator><![CDATA[or]]></dc:creator><pubDate>Thu, 05 Oct 2006 11:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 11:59:31 GMT]]></title><description><![CDATA[<p>or schrieb:</p>
<blockquote>
<p>von GetProcAddress gibt es keine Unicode-Variante. Das TEXT ist dort falsch. <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>
</blockquote>
<p>Ups dann wars genau anders herum <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/1149859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149859</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 11:59:31 GMT</pubDate></item><item><title><![CDATA[Reply to DLL einbinden und Funktion aus DLL aufrufen? on Thu, 05 Oct 2006 12:20:10 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Das könnte mir schon weiterhelfen. Ich muss es noch ausprobieren.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149882</guid><dc:creator><![CDATA[Bohr dir&#x27;n Loch ins Knie]]></dc:creator><pubDate>Thu, 05 Oct 2006 12:20:10 GMT</pubDate></item></channel></rss>