Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HINSTANCE (how to get the instance of a program)

minhtuanhtminhtuanht Posts: 1Member
How to get the HINSTANCE hInst.
I don't know any function that can help me do this.

Comments

  • LundinLundin Posts: 3,711Member
    : How to get the HINSTANCE hInst.
    : I don't know any function that can help me do this.
    :

    It is passed to main() at startup.
    It is passed to WM_CREATE in your windows message handling procedure.
    Besides that, you can get it with the function GetWindowLong().
  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2005-6-28 4:24:53[/red][/b][hr]
    : : How to get the HINSTANCE hInst.
    : : I don't know any function that can help me do this.
    : :
    :
    : It is passed to main() at startup.
    : It is passed to WM_CREATE in your windows message handling procedure.
    : Besides that, you can get it with the function GetWindowLong().
    :


    also, MSDN for WinMain() function (windows programs don't have main()), or if using MFC AfxGetInstanceHandle(). For console programs, call GetConsoleWindow() to get the HWND then GetWindowLong() to get the HINSTANCE.


  • MT2002MT2002 Posts: 1,444Member
    : [b][red]This message was edited by stober at 2005-6-28 4:24:53[/red][/b][hr]
    : : : How to get the HINSTANCE hInst.
    : : : I don't know any function that can help me do this.
    : : :
    : :
    : : It is passed to main() at startup.
    : : It is passed to WM_CREATE in your windows message handling procedure.
    : : Besides that, you can get it with the function GetWindowLong().
    : :
    :
    :
    : also, MSDN for WinMain() function (windows programs don't have main()), or if using MFC AfxGetInstanceHandle(). For console programs, call GetConsoleWindow() to get the HWND then GetWindowLong() to get the HINSTANCE.
    [blue]
    For the Win32 API, you could also use GetModuleHandle():[/blue]
    [code]
    [green]//get instance of current program (self)[/green]
    HINSTANCE hInst= GetModuleHandle (0);[/code]
Sign In or Register to comment.