Click here to Skip to main content
Click here to Skip to main content

Getting Dll Module Handle in ATL 7.0 projects

, 7 Mar 2002
Rate this:
Please Sign up or sign in to vote.
Simplest way to retrieve HINSTANCE of your ATL Object
<!-- Add the rest of your HTML here -->

Introduction

In ATL 7.0 the module statement in your main source file, automatically implements DllMain, DllRegisterServer and DllUnregisterServer for you.

The old fashioned way (not so old though) has been thrown away and _Module is not part of the implementation anymore.

Obviously Microsoft isn't much talking about it anyway, but this object was containing some handy properties that could be very useful in order to manipulate elements that are part of the DLL such as resources.

One way is to use the old GetModuleHandle() API function but in some cases it wouldn't work for you (and me as well).

So to get access to what was _Module in ATL 3.0 you simply use _AtlBaseModule.

AtlBaseModule has now succeeded to the old CComModule, pretty cool since there is no real mention of its data members in the documentation.

However instead of using directly m_hInst you could access it through methods such as GetModuleInstance(), GetResourceInstance() and GetHInstanceAt() for resource localization and internationalization  (thanx to Tim). Anyway, I hope it will solve your problem, like it has solved mine.

Really small example

HINSTANCE hInst = (HINSTANCE) _AtlBaseModule.m_hInst;<BR>HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(212));
Enjoy !!!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Deleted

United States United States
Whatever !

Comments and Discussions

 
GeneralThanks ! Pinmemberpg--az13-May-05 20:13 
Generalother way.... Pinmember=Hermitry=1-May-03 8:51 
GeneralCComModule... PinmemberTim Smith7-Mar-02 15:22 
GeneralRe: CComModule... PinmemberUnsigned Char7-Mar-02 19:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 8 Mar 2002
Article Copyright 2002 by Deleted
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid