Solved

Retrieving HINSTANCE

Posted on 2001-09-05
2
357 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
Comment Utility
'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
Comment Utility

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

Thanks!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

15 Experts available now in Live!

Get 1:1 Help Now