GetModuleHandle
In an attempt to get some diagnostics about which MFC installation is in use
by my application (some people have lots of them in WinSxS) I have been
trying
HINSTANCE hInstance = ::GetModuleHandle( _T("mfc80d.dll") );
if( hInstance )
{
TCHAR szPath[_MAX_PATH];
::GetModuleFileName( hInstance, szPath, _MAX_PATH );
::AfxMessageBox( szPath, MB_OK );
}
But GetModuleHandle is returning NULL.
If instead I try:
HINSTANCE hInstance = ::AfxLoadLibrary( _T("mfc80d.dll") );
if( hInstance )
{
TCHAR szPath[_MAX_PATH];
::GetModuleFileName( hInstance, szPath, _MAX_PATH );
::AfxMessageBox( szPath, MB_OK );
::AfxFreeLibrary( hInstance );
}
Then it works fine and I get *a* path to an MFC80D.DLL..
Any ideas
(a) why GetModuleHandle does not work
and more importantly
(b) whether the latter is always guaranteed to pick up the version of MFC
which my program has already loaded
(c) if there's a better way. (eg does the MFC DLL have a global hInstance
which it stores?)
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