Getting the instance handler from a console app
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.
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);
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)."
"If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file)."
That's exactly what you want. The handle of the calling process, which is your console application.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement