<?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 bleibt nicht in Nachrichtenschleife hängen]]></title><description><![CDATA[<p>Ich hab mein gesamtes Programm in der DLL (ich könnte, also die DLlMain einfach zu WinMain ändern und hätte nen normales .exe Programm), diese wird von ner .exe geladen und ich dachte mir, ich kann in der dll ganz normal mit Fenstern und ner Nachrichtenschleife arbeiten.<br />
Aber die Funktion in der die Nachrichtenschleife steckt, wird nicht so lange offen gehalten bis sie durch PostQuitMessage(0) beendet wird, sondern die Funktion beendet direkt.<br />
Die GUI und alles bleibt, aber erhalten bis es durch die zerstörten Objekte zu nem Fehler kommt.</p>
<p>Der Code der DllMain</p>
<pre><code class="language-cpp">int APIENTRY DllMain (HINSTANCE hinst, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
    {
        //Die DLL wird in den Adressraum des prozesses eingeblendet
        case DLL_PROCESS_ATTACH:
        {
            Frame* window = new Frame;
            App* app      = new App;

            //Initialisierung
            Singleton::getInstance().setHinst (hinst);
            Singleton::getInstance().setFramePtr (window);
            Singleton::getInstance().setAppPtr (app);

            //Fenster initialisieren
            window-&gt;init ();
            //App starten
            app-&gt;setup ();
            //Nachrichtenschleife starten
            window-&gt;run (); // HIER MÜSSTE DAS PROGRAMM STEHEN BLEIBEN TUT ES ABER NICHT
            //App beenden
            app-&gt;remove ();

            delete window;
            delete App;

            break;
        }
    }
    return TRUE;
}
</code></pre>
<p>Die Funktion run</p>
<pre><code class="language-cpp">bool Frame::run ()
{	MSG msg;
	//Nachrichtenschleife starten
	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	}
    return true;
}
</code></pre>
<p>Und die WndProc für die Nachrichten</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
	{
		switch (msg)
		{
			case WM_CREATE:
				// create
				return 0;

			case WM_DESTROY:
				PostQuitMessage (0);
				return 0;

		}

		return DefWindowProc (hwnd, msg, wparam, lparam);
	}
</code></pre>
<p>Die .exe die die DLL lädt</p>
<pre><code class="language-cpp">include &lt;windows.h&gt;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (IN HINSTANCE hinst, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
{
	static TCHAR szAppName[] = TEXT (&quot;KeyLogger&quot;); 
	MSG          msg; 
	HWND hwnd;
	WNDCLASSEX   wndclassex = {0}; 

	wndclassex.cbSize        = sizeof(WNDCLASSEX); 
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW; 
	wndclassex.lpfnWndProc   = WndProc; 
	wndclassex.cbClsExtra    = 0; 
	wndclassex.cbWndExtra    = 0; 
	wndclassex.hInstance     = hinst; 
	wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
	wndclassex.lpszMenuName  = NULL; 
	wndclassex.lpszClassName = szAppName; 
	wndclassex.hIconSm       = wndclassex.hIcon; 

	if (!RegisterClassEx (&amp;wndclassex)) 
	{ 
		MessageBox (NULL, TEXT (&quot;RegisterClassEx fehlgeschlagen!&quot;), szAppName, MB_ICONERROR); 
		return 0; 
	}

	hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil 
		szAppName, // Name der Fensterklasse 
		szAppName, // Fenstertitel 
		WS_OVERLAPPEDWINDOW, // Fensterstil 
		350, // X-Position des Fensters .... CW_USEDEFAULT für Default                      
		300, // Y-Position des Fensters        
		180, // Fensterbreite                  
		120, // Fensterhöhe                 
		NULL, // übergeordnetes Fenster 
		NULL, // Menü            
		hinst, // Programm-Kopiezähler (Programm-ID)             
		NULL); // zusätzliche Parameter 

	ShowWindow (hwnd, SW_SHOW); 
	UpdateWindow (hwnd); 

	HMODULE myLib = LoadLibrary (&quot;app.dll&quot;);

	if (myLib == NULL)
		MessageBox (0, &quot;error: mylib == NULL&quot;, &quot;error&quot;, MB_OK);

	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	} 

	FreeLibrary (myLib);
	return 0;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
		case WM_DESTROY:
			PostQuitMessage (0);
			return 0;
	}
	return DefWindowProc (hwnd, msg, wparam, lparam); 
}
</code></pre>
<p>Und jetzt die große Preisfrage: Was muss ich tun, damit die DLL in der Schleife hängen bleibt?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/85862/dll-bleibt-nicht-in-nachrichtenschleife-hängen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 04:16:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/85862.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Sep 2004 15:29:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 15:37:11 GMT]]></title><description><![CDATA[<p>Ich hab mein gesamtes Programm in der DLL (ich könnte, also die DLlMain einfach zu WinMain ändern und hätte nen normales .exe Programm), diese wird von ner .exe geladen und ich dachte mir, ich kann in der dll ganz normal mit Fenstern und ner Nachrichtenschleife arbeiten.<br />
Aber die Funktion in der die Nachrichtenschleife steckt, wird nicht so lange offen gehalten bis sie durch PostQuitMessage(0) beendet wird, sondern die Funktion beendet direkt.<br />
Die GUI und alles bleibt, aber erhalten bis es durch die zerstörten Objekte zu nem Fehler kommt.</p>
<p>Der Code der DllMain</p>
<pre><code class="language-cpp">int APIENTRY DllMain (HINSTANCE hinst, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
    {
        //Die DLL wird in den Adressraum des prozesses eingeblendet
        case DLL_PROCESS_ATTACH:
        {
            Frame* window = new Frame;
            App* app      = new App;

            //Initialisierung
            Singleton::getInstance().setHinst (hinst);
            Singleton::getInstance().setFramePtr (window);
            Singleton::getInstance().setAppPtr (app);

            //Fenster initialisieren
            window-&gt;init ();
            //App starten
            app-&gt;setup ();
            //Nachrichtenschleife starten
            window-&gt;run (); // HIER MÜSSTE DAS PROGRAMM STEHEN BLEIBEN TUT ES ABER NICHT
            //App beenden
            app-&gt;remove ();

            delete window;
            delete App;

            break;
        }
    }
    return TRUE;
}
</code></pre>
<p>Die Funktion run</p>
<pre><code class="language-cpp">bool Frame::run ()
{	MSG msg;
	//Nachrichtenschleife starten
	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	}
    return true;
}
</code></pre>
<p>Und die WndProc für die Nachrichten</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
	{
		switch (msg)
		{
			case WM_CREATE:
				// create
				return 0;

			case WM_DESTROY:
				PostQuitMessage (0);
				return 0;

		}

		return DefWindowProc (hwnd, msg, wparam, lparam);
	}
</code></pre>
<p>Die .exe die die DLL lädt</p>
<pre><code class="language-cpp">include &lt;windows.h&gt;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (IN HINSTANCE hinst, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
{
	static TCHAR szAppName[] = TEXT (&quot;KeyLogger&quot;); 
	MSG          msg; 
	HWND hwnd;
	WNDCLASSEX   wndclassex = {0}; 

	wndclassex.cbSize        = sizeof(WNDCLASSEX); 
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW; 
	wndclassex.lpfnWndProc   = WndProc; 
	wndclassex.cbClsExtra    = 0; 
	wndclassex.cbWndExtra    = 0; 
	wndclassex.hInstance     = hinst; 
	wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
	wndclassex.lpszMenuName  = NULL; 
	wndclassex.lpszClassName = szAppName; 
	wndclassex.hIconSm       = wndclassex.hIcon; 

	if (!RegisterClassEx (&amp;wndclassex)) 
	{ 
		MessageBox (NULL, TEXT (&quot;RegisterClassEx fehlgeschlagen!&quot;), szAppName, MB_ICONERROR); 
		return 0; 
	}

	hwnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil 
		szAppName, // Name der Fensterklasse 
		szAppName, // Fenstertitel 
		WS_OVERLAPPEDWINDOW, // Fensterstil 
		350, // X-Position des Fensters .... CW_USEDEFAULT für Default                      
		300, // Y-Position des Fensters        
		180, // Fensterbreite                  
		120, // Fensterhöhe                 
		NULL, // übergeordnetes Fenster 
		NULL, // Menü            
		hinst, // Programm-Kopiezähler (Programm-ID)             
		NULL); // zusätzliche Parameter 

	ShowWindow (hwnd, SW_SHOW); 
	UpdateWindow (hwnd); 

	HMODULE myLib = LoadLibrary (&quot;app.dll&quot;);

	if (myLib == NULL)
		MessageBox (0, &quot;error: mylib == NULL&quot;, &quot;error&quot;, MB_OK);

	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	} 

	FreeLibrary (myLib);
	return 0;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
		case WM_DESTROY:
			PostQuitMessage (0);
			return 0;
	}
	return DefWindowProc (hwnd, msg, wparam, lparam); 
}
</code></pre>
<p>Und jetzt die große Preisfrage: Was muss ich tun, damit die DLL in der Schleife hängen bleibt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606200</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Mon, 13 Sep 2004 15:37:11 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 17:22:38 GMT]]></title><description><![CDATA[<p>Kann's sein, dass du das falsche hInstance verwendest?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606269</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606269</guid><dc:creator><![CDATA[Ringding]]></dc:creator><pubDate>Mon, 13 Sep 2004 17:22:38 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 17:25:47 GMT]]></title><description><![CDATA[<p>Ne in der Winmain benutze ich ja das aus der WinMain parameterliste und in der DllMain das aus der DllMain parameterliste</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606273</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Mon, 13 Sep 2004 17:25:47 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 17:30:03 GMT]]></title><description><![CDATA[<p>Vielleicht solltest du überall die hInstance vom exe verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606277</guid><dc:creator><![CDATA[Ringding]]></dc:creator><pubDate>Mon, 13 Sep 2004 17:30:03 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 17:31:01 GMT]]></title><description><![CDATA[<p>Sowas programmiert man doch nicht direkt in die DllMain rein. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/606278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606278</guid><dc:creator><![CDATA[proggere]]></dc:creator><pubDate>Mon, 13 Sep 2004 17:31:01 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 17:54:03 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6165">@Ringding</a> hast recht, habe mir vorhin mal den Petzold organisiert und da stehts bei den DLLs auch dabei, man braucht in der DLL das HINSTANCE des Hauptprozesses, da die Nachrichten weiterhin über den laufen.</p>
<p>Kann ich mit ner Winapi Funktion das HINSTANCE meines Programmes ermitteln?<br />
Wäre schöner, als ne Funktion zu exportieren und im Hauptprogramm aufzurufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606287</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Mon, 13 Sep 2004 17:54:03 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 18:10:49 GMT]]></title><description><![CDATA[<p>HINSTANCE von EXE =&gt; GetModuleHandle(NULL);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606308</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606308</guid><dc:creator><![CDATA[proggerei]]></dc:creator><pubDate>Mon, 13 Sep 2004 18:10:49 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 18:21:37 GMT]]></title><description><![CDATA[<p>Danke, er kann das Handle zwar auslesen, aber die Message-Loop wird weiterhin sofort beendet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/606321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606321</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Mon, 13 Sep 2004 18:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 20:22:01 GMT]]></title><description><![CDATA[<p>Ich werd jetzt einfach in DLL_PROCESS_ATTACH nen Thread starten, dann hab ich ne eigene MessageLoop und die Probleme dürften erledigt sein. Damit die Fenster, aber meinem Thread gehören bzw. dessen MessageLoop muss ich ja beim erstellen das HINSTANCE Handle angeben, aber wie bekomm ich das von meinem Thread?<br />
Geht das mit GetModuleHandle (NULL)? Oder gibts dafür ne andere Variante?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606414</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Mon, 13 Sep 2004 20:22:01 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Mon, 13 Sep 2004 20:23:52 GMT]]></title><description><![CDATA[<p>hast du schonmal versucht das Fenster und die Message Loop ausserhalb der DllMain zu tun? also in einer seperaten Funktion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606416</guid><dc:creator><![CDATA[man19]]></dc:creator><pubDate>Mon, 13 Sep 2004 20:23:52 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 11:19:53 GMT]]></title><description><![CDATA[<p>man19 schrieb:</p>
<blockquote>
<p>hast du schonmal versucht das Fenster und die Message Loop ausserhalb der DllMain zu tun? also in einer seperaten Funktion</p>
</blockquote>
<p>Das Fenster und die Funktion sind ja seperat und ob DllMain jetzt noch ne funktion start() aufruft die genau den gleichen Code hat ändert ja nix daran, dass GetMessage in Frame::run() nicht funktioniert (PeekMessage geht, dann hab ich aber immer die Sanduhr)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606814</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 11:19:53 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 12:21:46 GMT]]></title><description><![CDATA[<p>Also mit nem Thread funktioniert es, allerdings bekommt mein Programm ständig WM_PAINT Nachrichten was dazu führt, dass ständig die Sanduhr un der normale Mauszeiger wechselt und erst, wenn ich das Fenster schließe sehe ich die MSG-Boxen die aus WM_PAINT kommen.</p>
<p>Könnt ihr euch das mal ansehen, woran es liegen könnt (bin aber immerhin auf dem richtigen weg, da es jetzt in der MSG Loop bleibt)?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;process.h&gt;

LRESULT CALLBACK WProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
	case WM_CREATE:
		MessageBox (0,&quot;WM_Create&quot;, &quot;msg&quot;, MB_OK);
		return 0;
	case WM_PAINT:
		MessageBox (0,&quot;WM_Paint&quot;, &quot;msg&quot;, MB_OK);
		return 0;
	case WM_DESTROY:
		MessageBox (0,&quot;WM_Destroy&quot;, &quot;msg&quot;, MB_OK);
		PostQuitMessage (0);
		return 0;
	}
	return DefWindowProc (hwnd, msg, wparam, lparam); 
}

void Thread (PVOID pvoid)
{
	static TCHAR szAppName[] = TEXT (&quot;DLL&quot;); 
	MSG          msg; 
	HWND hWnd;
	WNDCLASSEX   wndclassex = {0}; 

	wndclassex.cbSize        = sizeof(WNDCLASSEX); 
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW; 
	wndclassex.lpfnWndProc   = WProc; 
	wndclassex.cbClsExtra    = 0; 
	wndclassex.cbWndExtra    = 0; 
	wndclassex.hInstance     = (HINSTANCE)pvoid; 
	wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
	wndclassex.lpszMenuName  = NULL; 
	wndclassex.lpszClassName = szAppName; 
	wndclassex.hIconSm       = wndclassex.hIcon; 

	if (!RegisterClassEx (&amp;wndclassex)) 
	{ 
		MessageBox (NULL, TEXT (&quot;DLL RegisterClassEx fehlgeschlagen!&quot;), szAppName, MB_ICONERROR); 
		return;
	}

	hWnd = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, // erweiterter Fensterstil 
		szAppName, // Name der Fensterklasse 
		szAppName, // Fenstertitel 
		WS_OVERLAPPEDWINDOW, // Fensterstil 
		350, // X-Position des Fensters .... CW_USEDEFAULT für Default                      
		300, // Y-Position des Fensters        
		180, // Fensterbreite                  
		120, // Fensterhöhe                 
		NULL, // übergeordnetes Fenster 
		NULL, // Menü            
		(HINSTANCE)pvoid, // Programm-Kopiezähler (Programm-ID)             
		NULL); // zusätzliche Parameter 
	if (!hWnd)
	{
		MessageBox (0, &quot;CreateWindow in DLL fehlgeschlagen&quot;, &quot;info&quot;, MB_OK);
		return;
	}
	ShowWindow (hWnd, SW_SHOW); 
	UpdateWindow (hWnd); 

	while (GetMessage (&amp;msg, NULL, 0, 0)) 
	{ 
		TranslateMessage (&amp;msg); 
		DispatchMessage (&amp;msg); 
	} 
}

int APIENTRY DllMain (HINSTANCE hinst, DWORD fdwReason, PVOID pvReserved)
{
	switch (fdwReason)
	{
		case DLL_PROCESS_ATTACH:
			_beginthread (Thread, 0,  hinst);
			break;
		case DLL_PROCESS_DETACH:
			_endthread ();
			break;
	}
	return TRUE;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/606872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606872</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 12:21:46 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 12:27:42 GMT]]></title><description><![CDATA[<p>Zur Message-Loop in DllMain:</p>
<blockquote>
<p>The entry-point function should perform only simple initialization or termination tasks.</p>
</blockquote>
<p>Aber warum du mit PeekMessage Nachrichten bekommst und mit GetMessage nicht, ist auch seltsam <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>
]]></description><link>https://www.c-plusplus.net/forum/post/606881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606881</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 14 Sep 2004 12:27:42 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 12:50:44 GMT]]></title><description><![CDATA[<p>Das Beispiel aus meinem letzten Posting geht ja soweit, nur bekomm ich eben ununterbrochen WM_PAINT nachrichten, welche aber erst nach beenden des Fensters angezeigt werden. Aber das WM_DESTROY bekommt er nicht mit, da es anscheinend ab dem ersten WM_PAINT hängt.</p>
<p>Die exe und die dll sind beide als multithreaded Programme kompiliert, also daran kann es nicht liegen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606904</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 12:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 13:40:18 GMT]]></title><description><![CDATA[<p>Du hast wohl BeginPaint und EndPaint vergessen, oder lass DefWindowProc das Regeln. :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606974</guid><dc:creator><![CDATA[painter]]></dc:creator><pubDate>Tue, 14 Sep 2004 13:40:18 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 13:45:05 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">int APIENTRY DllMain (HINSTANCE hinst, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            _beginthread (Thread, 0,  hinst);
            break;
        case DLL_PROCESS_DETACH:
            _endthread ();
            break;
    }
    return TRUE;
}
</code></pre>
</blockquote>
<p>Bad idea. You should have a dedicated initialization function in the DLL<br />
that creates the thread and the dialog. You should only perform simple<br />
initializations in DllMain, read the documentation on DllMain.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606978</guid><dc:creator><![CDATA[Windowsprogger]]></dc:creator><pubDate>Tue, 14 Sep 2004 13:45:05 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 13:50:55 GMT]]></title><description><![CDATA[<p>painter schrieb:</p>
<blockquote>
<p>Du hast wohl BeginPaint und EndPaint vergessen, oder lass DefWindowProc das Regeln. :p</p>
</blockquote>
<p>Wow das klappt ja damit wirklich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
hab nicht gewusst, dass man in WM_PAINT &quot;zwangsweise&quot; beginpaint und endpaint benutzen muss</p>
<p>Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/606982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606982</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 13:50:55 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 13:56:29 GMT]]></title><description><![CDATA[<p>Windowsprogger schrieb:</p>
<blockquote>
<blockquote>
<pre><code class="language-cpp">int APIENTRY DllMain (HINSTANCE hinst, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            _beginthread (Thread, 0,  hinst);
            break;
        case DLL_PROCESS_DETACH:
            _endthread ();
            break;
    }
    return TRUE;
}
</code></pre>
</blockquote>
<p>Bad idea. You should have a dedicated initialization function in the DLL<br />
that creates the thread and the dialog. You should only perform simple<br />
initializations in DllMain, read the documentation on DllMain.</p>
</blockquote>
<p>Where else should I create the thread when I don't want to export a function for creating the thread und dialog.<br />
The only thing would be an asynchronous function which creates them else it would be the same thing only that DllMain<br />
calls another function which takes the same amount of time to initialize them.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/606987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606987</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 13:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 14:01:26 GMT]]></title><description><![CDATA[<blockquote>
<p>Where else should I create the thread when I don't want to export a function for creating the thread und dialog.</p>
</blockquote>
<p>Ok, if you don't want to export a seperate function, live with your dirty design. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/606995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/606995</guid><dc:creator><![CDATA[Windowsprogger]]></dc:creator><pubDate>Tue, 14 Sep 2004 14:01:26 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 14:28:41 GMT]]></title><description><![CDATA[<p>Windowsprogger schrieb:</p>
<blockquote>
<blockquote>
<p>Where else should I create the thread when I don't want to export a function for creating the thread und dialog.</p>
</blockquote>
<p>Ok, if you don't want to export a seperate function, live with your dirty design. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
</blockquote>
<p>It seems that I dont have the choide cause I've just discovered, that directly after the DLL_PROCESS_ATTACH call I get a DLL_PROCESS_DETACH call which destroys the thread and causes some trouble in my program (I get new DLL_PROCESS_ATTACH calls, but normally there should be only one).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/607032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607032</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 14:28:41 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 15:43:40 GMT]]></title><description><![CDATA[<p>Vielleicht hängt es damit zusammen:</p>
<blockquote>
<p>When a <strong>DLL is unloaded from a process as a result of an unsuccessful load of the DLL</strong>, termination of the process, or a call to FreeLibrary, the system does not call the DLL's entry-point function with the DLL_THREAD_DETACH value for the individual threads of the process. <strong>The DLL is</strong> only <strong>sent a DLL_PROCESS_DETACH notification</strong>.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/607110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607110</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 14 Sep 2004 15:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to DLL bleibt nicht in Nachrichtenschleife hängen on Tue, 14 Sep 2004 16:29:15 GMT]]></title><description><![CDATA[<p>Gut möglich, aber durch die exportierte Funktion welche jetzt den Thread erzeugt läuft es super <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Wieso kann ich eine exportierte Funktion die so aussieht EXPORT bool CALLBACK initialize (); nicht mit bool (CALLBACK *init_ptr)() laden?<br />
Bekomme, dann immer nen NULL Handle von GetProcAdress, wenn ich statt __stdcall __cdecl, also einfach nix dazu schreibe, benutze geht es <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>
]]></description><link>https://www.c-plusplus.net/forum/post/607149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/607149</guid><dc:creator><![CDATA[SirLant]]></dc:creator><pubDate>Tue, 14 Sep 2004 16:29:15 GMT</pubDate></item></channel></rss>