Solved

Retrieving HINSTANCE

Posted on 2001-09-05
2
358 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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.…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now