<?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[Mutex, DLL Problem]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich hab mal hier aus dem Forum den Tip bekommen wie man prüft, ob eine dll schon geladen ist, so dass sie bei einem zweiten Programm nicht geladen wird.<br />
Hab es dann wie folgt gemacht, doch meinProblem ist, dass ich den Ursprungszustand während der Laufzeit wiederherstellen muss, also das dieser Mutex wieder gelöscht wird.</p>
<pre><code class="language-cpp">AFX_MANAGE_STATE(AfxGetStaticModuleState())

	HRESULT nRet       = S_OK;
	char*   sMutexName = &quot;MUTEXIDENTIFIER&quot;; 
	DWORD   dwError    = 0; 

	CreateMutex(NULL, true, sMutexName); 

	dwError = GetLastError(); 

	if(ERROR_ALREADY_EXISTS == dwError)	// application is already running 
	{
		nRet  = DLL_IS_RUNNING;
		*pVal = FALSE;
	}
	else
	{
		*pVal = TRUE;
	}
</code></pre>
<p>Könnt ihr mir helfen?</p>
<p>Gruß,<br />
Stalin</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/65520/mutex-dll-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 11:57:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/65520.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Feb 2004 15:25:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mutex, DLL Problem on Thu, 19 Feb 2004 15:25:09 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich hab mal hier aus dem Forum den Tip bekommen wie man prüft, ob eine dll schon geladen ist, so dass sie bei einem zweiten Programm nicht geladen wird.<br />
Hab es dann wie folgt gemacht, doch meinProblem ist, dass ich den Ursprungszustand während der Laufzeit wiederherstellen muss, also das dieser Mutex wieder gelöscht wird.</p>
<pre><code class="language-cpp">AFX_MANAGE_STATE(AfxGetStaticModuleState())

	HRESULT nRet       = S_OK;
	char*   sMutexName = &quot;MUTEXIDENTIFIER&quot;; 
	DWORD   dwError    = 0; 

	CreateMutex(NULL, true, sMutexName); 

	dwError = GetLastError(); 

	if(ERROR_ALREADY_EXISTS == dwError)	// application is already running 
	{
		nRet  = DLL_IS_RUNNING;
		*pVal = FALSE;
	}
	else
	{
		*pVal = TRUE;
	}
</code></pre>
<p>Könnt ihr mir helfen?</p>
<p>Gruß,<br />
Stalin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463286</guid><dc:creator><![CDATA[Stalin]]></dc:creator><pubDate>Thu, 19 Feb 2004 15:25:09 GMT</pubDate></item><item><title><![CDATA[Reply to Mutex, DLL Problem on Thu, 19 Feb 2004 15:44:44 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>mit ReleaseMutex kannst du ein Mutex wieder &quot;löschen&quot;.</p>
<pre><code class="language-cpp">BOOL ReleaseMutex(
  HANDLE hMutex   // handle to mutex object
);
</code></pre>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463317</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Thu, 19 Feb 2004 15:44:44 GMT</pubDate></item><item><title><![CDATA[Reply to Mutex, DLL Problem on Thu, 19 Feb 2004 16:14:32 GMT]]></title><description><![CDATA[<p>Das funktioniert aber irgendwie nicht. Er denkt immer noch das der Mutex existert bzw. der Mutex existeriert weiter.<br />
Weiß jetzt nicht mehr weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463355</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463355</guid><dc:creator><![CDATA[Stalin]]></dc:creator><pubDate>Thu, 19 Feb 2004 16:14:32 GMT</pubDate></item><item><title><![CDATA[Reply to Mutex, DLL Problem on Thu, 19 Feb 2004 16:23:29 GMT]]></title><description><![CDATA[<p>ReleaseMutex gibt nur den (z.B. mi WaitForSingleObject aquirierten) Mutex wieder frei. Den Mutex löschen mit CloseHandle.</p>
<p>und:<br />
InitialOwner sollte man nur bei unbenannten Mutices verwenden</p>
<pre><code class="language-cpp">hm = CreateMutex(NULL, false, name);
if (!hm) { ... }
if (GetLastError() == ERROR_ALREADY_EXISTS)
{ 
  Mutex 
}

WaitForSingleObject(hm);  //&lt; brauchsat du wahrscheinlich nichtmal...
</code></pre>
<p>und irgendwann spätestens in DllMain(PROCESS_DETACH) den Mutex mit CloseHandle schließen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/463362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/463362</guid><dc:creator><![CDATA[peterchen]]></dc:creator><pubDate>Thu, 19 Feb 2004 16:23:29 GMT</pubDate></item></channel></rss>