CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    20

    How to get a HINSTANCE of the current programm ?

    Hi,
    even if it sounds like a joke, I mean it serious.

    Ok, for sure I know that this HINSTANCE is passed via arguments to WinMain.

    But what I want to do is, to write some C++-classes that need a HINSTANCE to to program they are used in, and for some reasons, I don't want to pass itfrom WinMain.

    So is there a possibility to get a HINSTANCE of the current module from anywhere inside the code ?

    thanks for your help

    highhead

  2. #2
    Join Date
    Apr 2002
    Posts
    86
    Use GetModuleHandle/Ex

  3. #3
    Join Date
    Apr 2004
    Posts
    20

    Thought about that initially

    Thanks again
    and you are sure a HMODULE is equal to a HINSTANCE ?

    regards

    highhead

  4. #4
    Join Date
    Apr 2002
    Posts
    86
    "As it turns out, HMODULEs and HINSTANCEs are exactly the same thing. If the documentation for a function indicates that an HMODULE is required, you can pass an HINSTANCE, and vice versa. There are two data types because in 16-bit Windows HMODULEs and HINSTANCEs identified different things." - Jeffrey Richter, Programming Applications for Microsoft Windows

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured