Solved

Retrieving HINSTANCE

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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