<?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[Thread in DLL ausführen]]></title><description><![CDATA[<p>Hi,</p>
<p>ich würde gern in einer DLL einen Thread ausführen. Leider bekomm ich beim Laden der DLL ein Segmentation Fault. Anbei mal mein Beispielcode:</p>
<p>DLL:</p>
<pre><code class="language-cpp">HANDLE aThread=NULL;

DWORD WINAPI einThread(LPVOID lpParameter)
{
   while(x)
   {
   something();
   }
}

extern &quot;C&quot; __declspec(dllexport) void startThread(void)
{
    aThread = CreateThread(NULL,0,einThread,NULL,0,NULL);

}
</code></pre>
<p>Main:</p>
<pre><code class="language-cpp">typedef void(* thread)(void);
HMODULE hModule=NULL;
thread th=NULL;

int main()
{
hModule=LoadLibrary(&quot;bla.dll&quot;);
if(hModule!=NULL)
{
th=(thread)GetProcAddress(hModule,&quot;startThread&quot;);
if(th!=NULL) th();
FreeLibrary(hModule);
}
Sleep(10000);
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/216887/thread-in-dll-ausführen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 13:09:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/216887.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Jun 2008 10:41:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 10:41:15 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich würde gern in einer DLL einen Thread ausführen. Leider bekomm ich beim Laden der DLL ein Segmentation Fault. Anbei mal mein Beispielcode:</p>
<p>DLL:</p>
<pre><code class="language-cpp">HANDLE aThread=NULL;

DWORD WINAPI einThread(LPVOID lpParameter)
{
   while(x)
   {
   something();
   }
}

extern &quot;C&quot; __declspec(dllexport) void startThread(void)
{
    aThread = CreateThread(NULL,0,einThread,NULL,0,NULL);

}
</code></pre>
<p>Main:</p>
<pre><code class="language-cpp">typedef void(* thread)(void);
HMODULE hModule=NULL;
thread th=NULL;

int main()
{
hModule=LoadLibrary(&quot;bla.dll&quot;);
if(hModule!=NULL)
{
th=(thread)GetProcAddress(hModule,&quot;startThread&quot;);
if(th!=NULL) th();
FreeLibrary(hModule);
}
Sleep(10000);
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1538424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538424</guid><dc:creator><![CDATA[sonofsun]]></dc:creator><pubDate>Mon, 30 Jun 2008 10:41:15 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 11:07:41 GMT]]></title><description><![CDATA[<p>Hast Du eine DllMain...?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538449</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538449</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 30 Jun 2008 11:07:41 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 11:09:05 GMT]]></title><description><![CDATA[<p>Nein ich benutz nur diese eine exportierte Funktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538451</guid><dc:creator><![CDATA[sonofsun]]></dc:creator><pubDate>Mon, 30 Jun 2008 11:09:05 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 11:33:18 GMT]]></title><description><![CDATA[<p><strong>Nachtrag:</strong><br />
SegmentationFault tritt nicht beim Laden der DLL auf, sonder beim Ausführen der Funktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538477</guid><dc:creator><![CDATA[sonofsun]]></dc:creator><pubDate>Mon, 30 Jun 2008 11:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 11:54:36 GMT]]></title><description><![CDATA[<p>versuchs mal mit</p>
<pre><code class="language-cpp">th=(thread)GetProcAddress(hModule,&quot;_startThread&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1538499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538499</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Mon, 30 Jun 2008 11:54:36 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Mon, 30 Jun 2008 13:10:24 GMT]]></title><description><![CDATA[<p>Problem gelöst:</p>
<p>lag am falsch gesetzten Sleep(), bzw. daran das der Thread noch am laufen war als ich FreeLibrary aufgerufen habe.<br />
Trotzdem Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538566</guid><dc:creator><![CDATA[sonofsun]]></dc:creator><pubDate>Mon, 30 Jun 2008 13:10:24 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Tue, 01 Jul 2008 06:51:55 GMT]]></title><description><![CDATA[<p>solltet du nicht prüfen obder Thread noch läuft bevor du</p>
<pre><code class="language-cpp">FreeLibrary(hModule);
</code></pre>
<p>machst?</p>
<p>sollte die</p>
<pre><code class="language-cpp">DWORD WINAPI einThread(LPVOID lpParameter)
</code></pre>
<p>nicht static sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538901</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Tue, 01 Jul 2008 06:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Thread in DLL ausführen on Tue, 01 Jul 2008 07:01:36 GMT]]></title><description><![CDATA[<blockquote>
<p>sollte die</p>
<pre><code class="language-cpp">DWORD WINAPI einThread(LPVOID lpParameter)
</code></pre>
<p>nicht static sein?</p>
</blockquote>
<p>Muss nicht. Global geht auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1538909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1538909</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 01 Jul 2008 07:01:36 GMT</pubDate></item></channel></rss>