HINSTANCE ermitteln
-
Hallo!
Ich schreibe eine DLL und brauche darin an einer Stelle dieses HINSTANCE, das normalerweise an die main übergeben wird.
Woher bekomme ich es in der DLL? Kann man es vielleicht an beliebiger Stelle per API-Aufruf abfragen (Windows muss doch wissen, woher der Aufruf kommt...)?
Ich möchte nämlich in der DLL ein Fenster erzeugen.
Danke schonmal!
mfg
-
(HINSTANCE)GetModuleHandle(NULL);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp
-
oder Du wertest die DLLMain aus und merkst dir den HINSTANCE Wert von da ...
Glaub GetModuleHandle macht nich grad unaufwendige Lookups, also um das "merken" wirst eh nich herumkommen, solange deine Funktionen in irgend einer weisse performant sein sollen ....
Ciao ...
-
miller_m schrieb:
(HINSTANCE)GetModuleHandle(NULL);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp
If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file).
-
RHBaum schrieb:
oder Du wertest die DLLMain aus und merkst dir den HINSTANCE Wert von da ...
bei mir dllmain hinstance != getmodulehandle
msdn schrieb:
hinstDLL
[in] Handle to the DLL module. The value is the base address of the DLL. The HINSTANCE of a DLL is the same as the HMODULE of the DLL, so hinstDLL can be used in calls to functions that require a module handle.msdn schrieb:
If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file).
[edit]
jetzt erst falsch gesehen. und warum sollte dieses falsch sein. ich erstelle meine fenster immer im selben prozess aus der dll heraus.