Sign in to follow this  
pasman

Getting the instance handler from a console app

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this