<?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 laden]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>wie kann ich eine Dll laden. Ich hab zwar einiges im Netz gefunden aber es gab immer irgendwelche Fehler.</p>
<p>Das ist der Code meiner Dll:</p>
<pre><code class="language-cpp">// erstelleDLL.h
namespace myNamespace{
	extern __declspec(dllexport) int meinDLL();
}
</code></pre>
<pre><code class="language-cpp">// erstelleDLL.cpp
#include &quot;erstelleDLL.h&quot;

int myNamespace::meinDLL(){
	return 888;
}
</code></pre>
<p>Und jetzt möchte ich die Funktion <strong>meinDLL()</strong> in einer Consoleanwendung benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/264146/dll-laden</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 04:59:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/264146.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Apr 2010 21:54:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL laden on Fri, 02 Apr 2010 21:54:22 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>wie kann ich eine Dll laden. Ich hab zwar einiges im Netz gefunden aber es gab immer irgendwelche Fehler.</p>
<p>Das ist der Code meiner Dll:</p>
<pre><code class="language-cpp">// erstelleDLL.h
namespace myNamespace{
	extern __declspec(dllexport) int meinDLL();
}
</code></pre>
<pre><code class="language-cpp">// erstelleDLL.cpp
#include &quot;erstelleDLL.h&quot;

int myNamespace::meinDLL(){
	return 888;
}
</code></pre>
<p>Und jetzt möchte ich die Funktion <strong>meinDLL()</strong> in einer Consoleanwendung benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877016</guid><dc:creator><![CDATA[ghostboss]]></dc:creator><pubDate>Fri, 02 Apr 2010 21:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Fri, 02 Apr 2010 21:57:23 GMT]]></title><description><![CDATA[<p>Ich verweise mal ganz dezent auf die folgende Seite:<br />
<a href="http://tinyurl.com/ydxwnt5" rel="nofollow">http://tinyurl.com/ydxwnt5</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877017</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Fri, 02 Apr 2010 21:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Fri, 02 Apr 2010 22:38:29 GMT]]></title><description><![CDATA[<p>Wie sehen die Fehler denn aus?<br />
Welcher Compiler wird benutzt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877026</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877026</guid><dc:creator><![CDATA[qcc]]></dc:creator><pubDate>Fri, 02 Apr 2010 22:38:29 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Fri, 02 Apr 2010 23:50:57 GMT]]></title><description><![CDATA[<p>Den Code habe ich schon überschrieben und mit dem Code kann gibts keine fehler beim Compiler aber wenn das Programm startet kommt ein Fehler:</p>
<pre><code class="language-cpp">int main(){
	typedef int (*pfunc)();
	HMODULE mod = LoadLibrary(L&quot;erstelleDLL.dll&quot;);

	if(mod != NULL)
		std::cout &lt;&lt; &quot;geladen&quot; &lt;&lt; std::endl;

	pfunc func = (pfunc)(GetProcAddress(mod,&quot;meinDLL&quot;));		

	int test = 0;
	test = func();
	std::cout &lt;&lt; test;

	FreeLibrary(mod);

    return 0;
}
</code></pre>
<p>Und ich mache das mit MS Visual C++ 08</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877038</guid><dc:creator><![CDATA[ghostboss]]></dc:creator><pubDate>Fri, 02 Apr 2010 23:50:57 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 00:05:07 GMT]]></title><description><![CDATA[<p>ghostboss schrieb:</p>
<blockquote>
<p>Den Code habe ich schon überschrieben und mit dem Code kann gibts keine fehler beim Compiler aber wenn das Programm startet kommt ein Fehler:</p>
</blockquote>
<p>Soso ein Fehler also. Das ist ja sehr genau ...</p>
<p>Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877039</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 03 Apr 2010 00:05:07 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 00:16:24 GMT]]></title><description><![CDATA[<p>Ja. Ich starte das Programm und dann wird es auch ausgefüht und nach 1 - 2 sek. kommt dann der Fehler &quot;programm.exe funktioniert nicht mehr ...&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877043</guid><dc:creator><![CDATA[ghostboss]]></dc:creator><pubDate>Sat, 03 Apr 2010 00:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 00:28:14 GMT]]></title><description><![CDATA[<p>Du prüfst nicht ausreichend auf NULL-Rückgabewerte.</p>
<pre><code class="language-cpp">int main(){
	typedef int (*pfunc)();
	HMODULE mod = LoadLibrary(L&quot;erstelleDLL.dll&quot;);

	if(mod != NULL) {
		std::cout &lt;&lt; &quot;geladen&quot; &lt;&lt; std::endl;

		pfunc func = (pfunc)(GetProcAddress(mod,&quot;meinDLL&quot;));		

		if (func) {
			int test = 0;
			test = func();
			std::cout &lt;&lt; test;
		}

		FreeLibrary(mod);
	}

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1877046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877046</guid><dc:creator><![CDATA[qcc]]></dc:creator><pubDate>Sat, 03 Apr 2010 00:28:14 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 00:38:02 GMT]]></title><description><![CDATA[<p>Jo danke kein Fehler mehr aber wie kann ich jetzt auf die Funktion zugreifen, die in der Dll ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877047</guid><dc:creator><![CDATA[ghostboss]]></dc:creator><pubDate>Sat, 03 Apr 2010 00:38:02 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 06:32:49 GMT]]></title><description><![CDATA[<p>Les dir die Doku genauer durch!<br />
Das Symbol heißt außerdem nicht &quot;meinDll&quot; sondern &quot;myNamespace::myDll&quot;.<br />
Ob das LoadLibrary kann, steht dann in der Doku. AFAIK geht das nicht, da LoadLibrary ne C-Funktion ist und da gibt es keinen namespace.<br />
Aber wie gesagt -&gt; Doku von Microsoft...<br />
Ahaja, und ein extern &quot;C&quot; sollte die zu ladende Funktion auch bekommen. Jedenfalls ist das unter Linux so (dlopen), und ich denke auch Windows wird das so wollen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877058</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Sat, 03 Apr 2010 06:32:49 GMT</pubDate></item><item><title><![CDATA[Reply to DLL laden on Sat, 03 Apr 2010 07:54:35 GMT]]></title><description><![CDATA[<p>Benutze den Dependency Walker um zu sehen wie der Name der exportierten Funktion genau heisst (bzw. ob überhaupt was exportiert wird):<br />
<a href="http://www.dependencywalker.com/" rel="nofollow">http://www.dependencywalker.com/</a></p>
<p>Falls deine Funktion nicht extern &quot;C&quot; ist (*.def File würde das automatisch machen) ist der Name durch Name mangling verändert. Siehst Du aber schnell im DW.</p>
<p>Ausserdem könnst Du für mehr info noch GetLastError() aufrufen.</p>
<p>Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1877063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1877063</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Sat, 03 Apr 2010 07:54:35 GMT</pubDate></item></channel></rss>