• Advertisement
Sign in to follow this  

Getting the instance handler from a console app

This topic is 4525 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

Hi, this might be a silly question, but I have a console C++ application with lots of console I/O, but I also need to create windows but I have to "fill in" the instance handler of the application. Is there a way to retrieve this other than using WinMain as an entry point to the application? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by pasman
Hi, this might be a silly question, but I have a console C++ application with lots of console I/O, but I also need to create windows but I have to "fill in" the instance handler of the application.

Is there a way to retrieve this other than using WinMain as an entry point to the application? Thank you.


I think you can do:
HINSTANCE hinstance = GetModuleHandle(0);

Share this post


Link to post
Share on other sites
Thanks, but reading through msdn I understand that GetModuleHandle works for dll and if I pass 0 as parameter...

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

Share this post


Link to post
Share on other sites
That's exactly what you want. The handle of the calling process, which is your console application.

Share this post


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

  • Advertisement