Solved

Retrieving HINSTANCE

Posted on 2001-09-05
2
361 Views
Last Modified: 2013-12-03
What's the easiest way to programatically obtain the HINSTANCE of the current app?

Some restraints:

1.  I'm writing a small little class that I want to be able to reuse, so I don't want to rely on a global variable.  

2.  I'm also trying to keep some APIs consistent, so I don't want to require the handle as a function or constructor parameter.  

3.  It's not MFC, so AfxGetInstanceHandle() is out of the question.

4.  I don't have a main window handle, so I can't use GetWindowLong().

I need the instance handle in order to call DialogBoxIndirectParam().  Is there another way to get around this?  I know I've figured this out before, but now I'm blanking and getting frustrated.  Anyone know this offhand?

Thanks!
0
Comment
Question by:The Master
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 6459244
'GetModuleHandle()' is the way to go - HMODULE and HINSTANCE anre interchangeable, so you can get your application instance handle using 'GetModuleHandle( NULL);'
0
 
LVL 2

Author Comment

by:The Master
ID: 6459298

Doh...of course!  Argh....

Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question