<?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[Klasse aus Dll]]></title><description><![CDATA[<p>Kann ich eine Klasse aus einer Dll dynamisch laden?<br />
Ich meine ohne Importbibliothek.<br />
Wenn nein, könnte mir dann bitte jemand erklären wie ich so eine Importbibliothek erstelle?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124343/klasse-aus-dll</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 08:31:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124343.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Oct 2005 16:22:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Klasse aus Dll on Wed, 26 Oct 2005 16:22:29 GMT]]></title><description><![CDATA[<p>Kann ich eine Klasse aus einer Dll dynamisch laden?<br />
Ich meine ohne Importbibliothek.<br />
Wenn nein, könnte mir dann bitte jemand erklären wie ich so eine Importbibliothek erstelle?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901312</guid><dc:creator><![CDATA[cj]]></dc:creator><pubDate>Wed, 26 Oct 2005 16:22:29 GMT</pubDate></item><item><title><![CDATA[Reply to Klasse aus Dll on Wed, 26 Oct 2005 18:35:51 GMT]]></title><description><![CDATA[<p>klar kannst du<br />
header:</p>
<pre><code class="language-cpp">class IMyClass
{
public:
   virtual void Release() = 0;
   virtual void DoIt() = 0;
}

typedef IMyClass* (*MyClassFactoryPtr)(void); 
#define MyClassFactoryName TEXT(&quot;CreateMyClass&quot;)
</code></pre>
<p>in deiner dll:</p>
<pre><code class="language-cpp">class CMyClassImpl : public IMyClass
{
public:
   virtual void Release() { delete this; }
   virtual void DoIt()
   {
     ...
   }
}

__declspec( dllexport ) IMyClass* CreateMyClass()
{
   return new CMyClassImpl;
}
</code></pre>
<p>in deiner exe</p>
<pre><code class="language-cpp">int main()
{
   HINSTANCE hDll = LoadLibaray(&quot;DeineDll.dll&quot;);
   if(hDll==NULL)
     return 1;
   MyClassFactoryPtr creator= (MyClassCreatorPtr)GetProcAddress(hDll, MyClassFactoryName); 
   if(creator==NULL)
     retrun 1;

   IMyClass *myClass = (creator)();
   myClass-&gt;DoIt();
   myClass-&gt;Release();
   return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/901448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901448</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Wed, 26 Oct 2005 18:35:51 GMT</pubDate></item></channel></rss>