<?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 Klassen funktionen aufrufen]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche eine Funktion aus einer dll Klasse aufzurufen, aber ich weiss nicht wirklich wie ich das machen kann...</p>
<p>Hier mal mein Beispiel Programm von mir:</p>
<p>Fuer die DLL:<br />
&lt;&lt;&lt;dlltest.h&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#ifndef _DLLTEST_H_
 #define _DLLTEST_H_

 #include &lt;iostream&gt;
 #include &lt;windows.h&gt;

 extern &quot;C&quot; __declspec(dllexport) void NumberList();

 class MyClass
 {
 private:
    MyClass();
    ~MyClass();
 public:
    void LetterList();
 };
 #endif
</code></pre>
<p>&lt;&lt;&lt;dlltest.cpp&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#include &quot;dlltest.h&quot;

 using namespace std;

 void NumberList() {

       cout &lt;&lt; &quot;NumberList(): &quot;;
       for(int i=0;  i&lt;10; i++) {
            cout &lt;&lt; i &lt;&lt; &quot; &quot;;
       }
       cout &lt;&lt; endl;
 }

 MyClass::MyClass(){}
 MyClass::~MyClass(){}

 void MyClass::LetterList()
{
       cout &lt;&lt; &quot;LetterList(): &quot;;
       for(int i=0;  i&lt;26; i++) {
            cout &lt;&lt; char(97 + i) &lt;&lt; &quot; &quot;;
       }
       cout &lt;&lt; endl &lt;&lt; endl;
 }
</code></pre>
<p>und fuer die Anwendung...<br />
&lt;&lt;&lt;main.cpp&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;conio.h&gt; //wait on user reaction - _getch() -

 typedef void (WINAPI* cfunc)();

 using namespace std;

 cfunc NumberList;
 cfunc LetterList;
 int main() {

    cout &lt;&lt; &quot;Loading library...&quot;;
    HINSTANCE hLib=LoadLibrary(&quot;TheDLL.dll&quot;);

    if(hLib==NULL)
        {cout &lt;&lt; &quot;Faild! Unable to load library!&quot; &lt;&lt; endl;}
    else
        {cout &lt;&lt; &quot;Done!&quot; &lt;&lt; endl;}

    cout &lt;&lt; &quot;Loading function...&quot;;
    NumberList=(cfunc)GetProcAddress((HMODULE)hLib, &quot;NumberList&quot;);

    if((NumberList==NULL))
    {
        cout &lt;&lt; &quot;Faild! Unable to load function.&quot; &lt;&lt; endl;
        _getch();//wait on user reaction
    }
    else
    {
        cout &lt;&lt; &quot;Done!&quot; &lt;&lt; endl;
        NumberList();
    }

    FreeLibrary((HMODULE)hLib);
    _getch();//wait on user reaction
    return 0;
 }
</code></pre>
<p>Wie kann ich die Klassenfunktion LetterList aufrufen? <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>Danke schonmal<br />
Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/242801/dll-klassen-funktionen-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 20:14:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/242801.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Jun 2009 12:31:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL Klassen funktionen aufrufen on Mon, 08 Jun 2009 12:31:34 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche eine Funktion aus einer dll Klasse aufzurufen, aber ich weiss nicht wirklich wie ich das machen kann...</p>
<p>Hier mal mein Beispiel Programm von mir:</p>
<p>Fuer die DLL:<br />
&lt;&lt;&lt;dlltest.h&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#ifndef _DLLTEST_H_
 #define _DLLTEST_H_

 #include &lt;iostream&gt;
 #include &lt;windows.h&gt;

 extern &quot;C&quot; __declspec(dllexport) void NumberList();

 class MyClass
 {
 private:
    MyClass();
    ~MyClass();
 public:
    void LetterList();
 };
 #endif
</code></pre>
<p>&lt;&lt;&lt;dlltest.cpp&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#include &quot;dlltest.h&quot;

 using namespace std;

 void NumberList() {

       cout &lt;&lt; &quot;NumberList(): &quot;;
       for(int i=0;  i&lt;10; i++) {
            cout &lt;&lt; i &lt;&lt; &quot; &quot;;
       }
       cout &lt;&lt; endl;
 }

 MyClass::MyClass(){}
 MyClass::~MyClass(){}

 void MyClass::LetterList()
{
       cout &lt;&lt; &quot;LetterList(): &quot;;
       for(int i=0;  i&lt;26; i++) {
            cout &lt;&lt; char(97 + i) &lt;&lt; &quot; &quot;;
       }
       cout &lt;&lt; endl &lt;&lt; endl;
 }
</code></pre>
<p>und fuer die Anwendung...<br />
&lt;&lt;&lt;main.cpp&gt;&gt;&gt;</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;conio.h&gt; //wait on user reaction - _getch() -

 typedef void (WINAPI* cfunc)();

 using namespace std;

 cfunc NumberList;
 cfunc LetterList;
 int main() {

    cout &lt;&lt; &quot;Loading library...&quot;;
    HINSTANCE hLib=LoadLibrary(&quot;TheDLL.dll&quot;);

    if(hLib==NULL)
        {cout &lt;&lt; &quot;Faild! Unable to load library!&quot; &lt;&lt; endl;}
    else
        {cout &lt;&lt; &quot;Done!&quot; &lt;&lt; endl;}

    cout &lt;&lt; &quot;Loading function...&quot;;
    NumberList=(cfunc)GetProcAddress((HMODULE)hLib, &quot;NumberList&quot;);

    if((NumberList==NULL))
    {
        cout &lt;&lt; &quot;Faild! Unable to load function.&quot; &lt;&lt; endl;
        _getch();//wait on user reaction
    }
    else
    {
        cout &lt;&lt; &quot;Done!&quot; &lt;&lt; endl;
        NumberList();
    }

    FreeLibrary((HMODULE)hLib);
    _getch();//wait on user reaction
    return 0;
 }
</code></pre>
<p>Wie kann ich die Klassenfunktion LetterList aufrufen? <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>Danke schonmal<br />
Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1723228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1723228</guid><dc:creator><![CDATA[MrMoeste]]></dc:creator><pubDate>Mon, 08 Jun 2009 12:31:34 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Klassen funktionen aufrufen on Mon, 08 Jun 2009 12:55:48 GMT]]></title><description><![CDATA[<p>LetterList ist keine Klassenfunktion. Sie ist an ein Objekt gebunden, d.h. brauchst du ein Objekt. Leider sehe ich in deinem Quelltext erstmal nur NumberList. Auch weiss ich nicht, was deine typedefs da tun und machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1723243</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1723243</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Mon, 08 Jun 2009 12:55:48 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Klassen funktionen aufrufen on Mon, 08 Jun 2009 13:24:19 GMT]]></title><description><![CDATA[<p>Ja genau, ich versuch die Funktion LetterList aufzurufen.</p>
<p>Die typdef dienen zum zugriff auyf die dll. Ich hab mir den Code aus dem netz zusammengebastelt..drum versteh ich auch nciht bis in die letzte Einzelheit.</p>
<p>Hilft dir das weiter?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1723262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1723262</guid><dc:creator><![CDATA[MrMoeste]]></dc:creator><pubDate>Mon, 08 Jun 2009 13:24:19 GMT</pubDate></item><item><title><![CDATA[Reply to DLL Klassen funktionen aufrufen on Mon, 08 Jun 2009 14:24:05 GMT]]></title><description><![CDATA[<p>MrMoeste schrieb:</p>
<blockquote>
<p>Ja genau, ich versuch die Funktion LetterList aufzurufen.</p>
</blockquote>
<p>Nur das LetterList nicht die verlangte Signatur hat. Eine nicht-statische Methode (Funktion einer Klasse) benötigt im Gegensatz zu einer Funktion immer 2 Zeiger (Zeiger auf Methode und Zeiger auf Objekt).</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1723305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1723305</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 08 Jun 2009 14:24:05 GMT</pubDate></item></channel></rss>