<?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[Fehler beim dynamischen Linken von Dlls]]></title><description><![CDATA[<p>Hallo,<br />
Neuerdings fällt mir auf, dass wenn ich Dlls dynamisch lade, das Programm nach der Ausführung der Funktion abkratzt.<br />
Ich muss jetzt immer try und catch benutzen, damit das Programm nicht abstürzt.</p>
<p>Bsp:</p>
<pre><code class="language-cpp">typedef int (WINAPI* IMPFUNC)(int,int); // Funktionspointer
HMODULE hDll=LoadLibrary(_T(&quot;DynLib.dll&quot;));
if(hDll)
{
	IMPFUNC Test =(IMPFUNC) GetProcAddress(hDll,&quot;Test&quot;);
	TCHAR* buffer=new TCHAR[256];
	if(Test)
	{
		try
		{
			int x=Test(50,5);
			wsprintf(buffer,_T(&quot;Value returned from Dll: %d&quot;),x);
		} 
		catch(...)
		{
			MessageBox(0,_T(&quot;Fehler&quot;),0,0);
		}
	}
	else
	{
		wsprintf(buffer,_T(&quot;%d&quot;),GetLastError());
	}
	MessageBox(0,buffer,0,MB_ICONASTERISK);
	delete [] buffer;
	FreeLibrary(hDll);
}
else
{
	MessageBox(0,_T(&quot;DynLib.dll konnte nicht geladen werden!&quot;),0,0);
}
</code></pre>
<p>Die Funktion 'Test' in DynLib.dll multipliziert die beiden Werte.<br />
Es wird auch 250 angezeigt!!!<br />
'Fehler' wird nicht angezeigt.<br />
Wenn ich aber den try-catch Block weglasse, so stürzt das Programm ab.(nur wenn die Funktion in der Dll Parameter hat)</p>
<p>Muss ich jetzt immer diesen try-catch Block anlegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/138120/fehler-beim-dynamischen-linken-von-dlls</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 22:43:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/138120.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Feb 2006 14:32:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler beim dynamischen Linken von Dlls on Thu, 23 Feb 2006 14:32:03 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Neuerdings fällt mir auf, dass wenn ich Dlls dynamisch lade, das Programm nach der Ausführung der Funktion abkratzt.<br />
Ich muss jetzt immer try und catch benutzen, damit das Programm nicht abstürzt.</p>
<p>Bsp:</p>
<pre><code class="language-cpp">typedef int (WINAPI* IMPFUNC)(int,int); // Funktionspointer
HMODULE hDll=LoadLibrary(_T(&quot;DynLib.dll&quot;));
if(hDll)
{
	IMPFUNC Test =(IMPFUNC) GetProcAddress(hDll,&quot;Test&quot;);
	TCHAR* buffer=new TCHAR[256];
	if(Test)
	{
		try
		{
			int x=Test(50,5);
			wsprintf(buffer,_T(&quot;Value returned from Dll: %d&quot;),x);
		} 
		catch(...)
		{
			MessageBox(0,_T(&quot;Fehler&quot;),0,0);
		}
	}
	else
	{
		wsprintf(buffer,_T(&quot;%d&quot;),GetLastError());
	}
	MessageBox(0,buffer,0,MB_ICONASTERISK);
	delete [] buffer;
	FreeLibrary(hDll);
}
else
{
	MessageBox(0,_T(&quot;DynLib.dll konnte nicht geladen werden!&quot;),0,0);
}
</code></pre>
<p>Die Funktion 'Test' in DynLib.dll multipliziert die beiden Werte.<br />
Es wird auch 250 angezeigt!!!<br />
'Fehler' wird nicht angezeigt.<br />
Wenn ich aber den try-catch Block weglasse, so stürzt das Programm ab.(nur wenn die Funktion in der Dll Parameter hat)</p>
<p>Muss ich jetzt immer diesen try-catch Block anlegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1001154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1001154</guid><dc:creator><![CDATA[qasdfgh]]></dc:creator><pubDate>Thu, 23 Feb 2006 14:32:03 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim dynamischen Linken von Dlls on Thu, 23 Feb 2006 14:59:00 GMT]]></title><description><![CDATA[<p>Und wie sieht Test aus? Benutzt die wirklich __stdcall (WINAPI) Aufrufkonvention?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1001185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1001185</guid><dc:creator><![CDATA[test!]]></dc:creator><pubDate>Thu, 23 Feb 2006 14:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim dynamischen Linken von Dlls on Thu, 23 Feb 2006 15:06:07 GMT]]></title><description><![CDATA[<p>Danke.<br />
Daran lag es wohl.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1001195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1001195</guid><dc:creator><![CDATA[qasdfgh]]></dc:creator><pubDate>Thu, 23 Feb 2006 15:06:07 GMT</pubDate></item></channel></rss>