VC++: Weird problem with DLLs
Posted on 1998-02-16
I am trying to figure out how to use other peoples' DLLs in Visual C++, but for some reason I can't seem to load the DLL into memory. I tried the following:
Created a new MFC application (.exe) and added the following code fragment anywhere (for example in CTestView::OnDraw):
HINSTANCE hlib = AfxLoadLibrary("commdlg.dll");
DWORD error = GetLastError();
When I step through this code I see that hlib obtains the value 0 (load failure) and error is equal to 31, which is the error code for General Failure Error. What in the world does a general failure error have to do with loading a DLL? The same result occurs regardless of the DLL I am using (I used commdlg.dll because I know it's a DLL that works). I know that error 31 is originating from AfxLoadLibrary because when I use GetLastError before the call to AfxLoadLibrary I get an error code 0 (success).
What is going on here? I doubt the General Failure error is really what's going on because everything in my OS is working properly (including things that other programs load from the commdlg.dll library). How can I solve this problem?
(Please don't tell me that I can use MFC functions that call commdlg.dll. I've already tried it, and it works. That library name is only an example. The same result happens no matter what DLL I try to load, this is just so that you can try the above code fragment on your computer if you want).
Thanks in advance!