HINSTANCE (how to get the instance of a program)

Ok, I've seen the old post on this.
However, this is specific to a Windows Service. The main function on a service is like a console app, you get argc, char *argv[] with command line parameters.

There are no registered Window objects, there is no WinMain().

I am storing a resource in the service, but in order to extract it, it wants an HINSTANCE handle.


  • HWND hwndC = GetConsoleWindow() ;
    HINSTANCE hInst = (HINSTANCE)GetWindowLong( hwndC, GWL_HINSTANCE );
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion