Jump to content
  • Advertisement
Sign in to follow this  
OleKaiwalker

GetModuleHandle

This topic is 4760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, When using GetModuleHandle with NULL as the argument which instance do I recieve? Is it the same one as the one which is parsed to you through WinMain??

Share this post


Link to post
Share on other sites
Advertisement
if your calling it from an .exe yes, its the same as the one in winmain. If you call it from a DLL you get the main program's instance, not the DLL you call the function from. I could be wrong, but I believe thats correct.

Share this post


Link to post
Share on other sites
From MSDN:

If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process.

Share this post


Link to post
Share on other sites
Quote:
Original post by BRooksWackerman
From MSDN:

If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process.


I'm almost positive it doesn't work like that for DLLs, however. It will return the process that is using the DLL

As for what it means, it means it gets the handle to the .exe, or calling process

Share this post


Link to post
Share on other sites
The file used to create the calling process is your program (if you're writing an exe) or the program that loaded your dll (if you're writing a dll) - as moeron pointed out. GetModuleHandle(NULL) typically returns the value 0x00400000. This is where the program itself is loaded into the memory address space of the process.

Share this post


Link to post
Share on other sites
It will work. HINSTANCE and HMODULE are the same thing. HINSTANCE is leftover from the dark days of 16 bit Windows.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!