Re: GetModuleHandle
On Sat, 3 Mar 2007 17:30:12 -0000, "David Webber"
<dave@musical.demon.co.uk> wrote:
No - I am actually planning
#ifdef _DEBUG
HINSTANCE hInstance = ::GetModuleHandle( _T("mfc80d.dll") );
#else
HINSTANCE hInstance = ::GetModuleHandle( _T("mfc80.dll") );
#endif
but for the moment, while I try and get it functional, I was working with
the debug version of the program
If it's your release mode version, it isn't working because it's using
mfc80.dll.
No, I'm pretty sure that's not it.
and more importantly
(b) whether the latter is always guaranteed to pick up the version of MFC
which my program has already loaded
No, it will happily load the DLL if necessary.
Yes, but assuming I have it loaded, and I don't specify a path, should it
always find the loaded one?
Yes.
Not that I know of. What you've written should work fine; you just have to
ask for the right DLL.
Thanks - I'll try the release version and see what happens.
I tried this little console program and it worked as expected.
#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