Re: GetModuleHandle
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:k1dju2548pd636ikmcs5cc0fklc2toq6oo@4ax.com...
I tried this little console program and it worked as expected.
...
Thanks for your efforts: my result is weird!
My revised effort does:
HINSTANCE hInstanceD = ::GetModuleHandle( _T("mfc80d.dll") );
and on getting NULL does a get last error .
Then it does
HINSTANCE hInstanceR = ::GetModuleHandle( _T("mfc80.dll") );
and on getting NULL does a get last error .
For both debug and release versions the answer is that the module was not
found.
I am doing this from code inserted into a command handler in my CView
derived class, while I can see the CView and all the mainframe windows up on
the screen in front of me - so some version of mfc80.dll MUST be around
somewhere!
I am running with F5 and Ctrl+F5 from inside VS2005 - but surely that should
make no difference????
Is there a way to enumerate all the instance handles of the DLLs which have
been loaded by one's exe?
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
..
#include <afx.h>
int main()
{
#ifdef _DEBUG
HINSTANCE hInstance = ::GetModuleHandle(_T("mfc80d.dll"));
#else
HINSTANCE hInstance = ::GetModuleHandle(_T("mfc80.dll"));
#endif
if (hInstance)
{
TCHAR szPath[_MAX_PATH];
::GetModuleFileName(hInstance, szPath, _MAX_PATH);
puts(szPath);
}
}
X>cl -MD -D_AFXDLL a.cpp
X>a
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_3bf
8fa05\MFC80.DLL
X>cl -MDd -D_DEBUG -D_AFXDLL a.cpp
X>a
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.762_x-w
w_257740a4\MFC80D.DLL
--
Doug Harrison
Visual C++ MVP