<?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[DialogBoxParam und HINSTANCE Problem]]></title><description><![CDATA[<p>Hallo @all,</p>
<p>ich habe ein Problem mit meiner Resource. Ich verwende DialogBoxParam um aus dieser eine Dialog zu erstellen und übergebe als ersten Parameter (Hinstance) NULL, da dies meinen Prozess identifiziert. Wenn sich mein Code jetzt allerdings in einer DLL befindet, funktioniert das nicht mehr, da die Resource in der DLL und nicht in der EXE ist. Soweit richtig?</p>
<p>Okay, nun meine Frage. Wie kann ich ein Handle auf mein Modul (EXE/DLL) bekommen?</p>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/156213/dialogboxparam-und-hinstance-problem</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Jul 2026 08:47:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/156213.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Aug 2006 17:33:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 17:33:48 GMT]]></title><description><![CDATA[<p>Hallo @all,</p>
<p>ich habe ein Problem mit meiner Resource. Ich verwende DialogBoxParam um aus dieser eine Dialog zu erstellen und übergebe als ersten Parameter (Hinstance) NULL, da dies meinen Prozess identifiziert. Wenn sich mein Code jetzt allerdings in einer DLL befindet, funktioniert das nicht mehr, da die Resource in der DLL und nicht in der EXE ist. Soweit richtig?</p>
<p>Okay, nun meine Frage. Wie kann ich ein Handle auf mein Modul (EXE/DLL) bekommen?</p>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117171</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 14 Aug 2006 17:33:48 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 17:57:06 GMT]]></title><description><![CDATA[<pre><code>GetModuleHandle
The GetModuleHandle function returns a module handle for the specified module if the file has been mapped into the address space of the calling process. 

HMODULE GetModuleHandle(
  LPCTSTR lpModuleName   // address of module name to return handle 
                         // for
);

Parameters
lpModuleName 
Pointer to a null-terminated string that contains the name of the module (either a .DLL or .EXE file). If the filename extension is omitted, the default library extension .DLL is appended. The filename string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) to the names of modules currently mapped into the address space of the calling process. 
If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process. 

Return Values
If the function succeeds, the return value is a handle to the specified module.

If the function fails, the return value is NULL. To get extended error information, call GetLastError. 

Remarks
The returned handle is not global, inheritable, or duplicative, and it cannot be used by another process. 

The handles returned by GetModuleHandle and LoadLibrary can be used in the same functions — for example, GetProcAddress, FreeLibrary, orLoadResource. The difference between the two functions involves the reference count. LoadLibrary maps the module into the address space of the calling process, if necessary, and increments the module's reference count, if it is already mapped. GetModuleHandle, however, returns the handle to a mapped module without incrementing its reference count. 

Note that the reference count is used in FreeLibrary to determine whether to unmap the function from the address space of the process. For this reason, use care when using a handle returned by GetModuleHandle in a call to FreeLibrary because doing so can cause a dynamic-link library (DLL) module to be unmapped prematurely. 

This function must also be used carefully in a multithreaded application. There is no guarantee that the module handle remains valid between the time this function returns the handle and the time it is used by another function. For example, a thread might retrieve a module handle by calling GetModuleHandle. Before the thread uses the handle in another function, a second thread could free the module and the system could load another module, giving it the same handle as the module that was recently freed. The first thread would then be left with a module handle that refers to a module different than the one intended. 

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1117180</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117180</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 14 Aug 2006 17:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 17:57:56 GMT]]></title><description><![CDATA[<p>GetModuleHandle</p>
<p>Bin mir aber ni9cht sicher, ob das das richtige Handle liefert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117181</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 14 Aug 2006 17:57:56 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 18:43:20 GMT]]></title><description><![CDATA[<p>Das wird dir in dem Fall das DLL Handle retunieren ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117209</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 14 Aug 2006 18:43:20 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 19:53:34 GMT]]></title><description><![CDATA[<p>Das funktioniert aber nur wenn ich den Modulnamen weiß, den kann ich aber doch nur über GetModuleFileName herausfinden,<br />
was wieder das Handle auf das Modul benötigt. Ich drehe mich damit im Kreis.</p>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117247</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 14 Aug 2006 19:53:34 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 20:21:42 GMT]]></title><description><![CDATA[<p>Du verklickerst deiner DLL - nachdem du sie geladen hast - wer dein Prozess ist?</p>
<p>Greetz, Sowrdfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117261</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 14 Aug 2006 20:21:42 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Mon, 14 Aug 2006 20:39:12 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>Du verklickerst deiner DLL - nachdem du sie geladen hast - wer dein Prozess ist?</p>
</blockquote>
<p>Irgendwie verstehe ich nicht was du meinst. Ich möchte ein Handle auf mich (die DLL). Wenn ich ein Handle auf den Prozess will, kann ich bei GetModuleHandle auch NULL übergeben.</p>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117275</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117275</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Mon, 14 Aug 2006 20:39:12 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Tue, 15 Aug 2006 09:59:07 GMT]]></title><description><![CDATA[<p>Entschuldige, ich hab' dich offensichtlich wirklich falsch verstanden. Du hast also eine DLL mit ressource. In dieser DLL willt du <em>DialogBoxParam( )</em> aufrufen, den Dialog aus der DLL zu verwenden? Dann versteh' ich dein Problem nicht, denn in</p>
<pre><code class="language-cpp">int __stdcall DllMain( HINSTANCE instance, unsigned long reason, void *reserved )
{
    return 1;
}
</code></pre>
<p>erhältst du ein Handle (instance) auf deine DLL.</p>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117424</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Tue, 15 Aug 2006 09:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Tue, 15 Aug 2006 10:33:33 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>Entschuldige, ich hab' dich offensichtlich wirklich falsch verstanden. Du hast also eine DLL mit ressource. In dieser DLL willt du <em>DialogBoxParam( )</em> aufrufen, den Dialog aus der DLL zu verwenden? Dann versteh' ich dein Problem nicht, denn in</p>
<pre><code class="language-cpp">int __stdcall DllMain( HINSTANCE instance, unsigned long reason, void *reserved )
{
    return 1;
}
</code></pre>
<p>erhältst du ein Handle (instance) auf deine DLL.</p>
<p>Greetz, Swordfish</p>
</blockquote>
<p>Stimmt ja, in einer DLL kann ich das so machen. Ich möchte meinen Code aber auch mal als statische Lib benutzen, habe ich da ein eine <em>DllMain</em>? Habe noch nie eine statische Lib erstellt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>Gruß<br />
yogle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117443</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Tue, 15 Aug 2006 10:33:33 GMT</pubDate></item><item><title><![CDATA[Reply to DialogBoxParam und HINSTANCE Problem on Tue, 15 Aug 2006 13:29:38 GMT]]></title><description><![CDATA[<p>Nur so neben bei.... GetModuleHandle(0) <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1117610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1117610</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Tue, 15 Aug 2006 13:29:38 GMT</pubDate></item></channel></rss>