LoadLibrary() returning NULL

Started by
13 comments, last by Zlodo 15 years, 3 months ago
Quote:Original post by DOrmisher
When I created the dll I used a win32 dll project, will this make any difference? Do you need to create an MFC DLL project for it to load correctly in an MFC app?
Nope. There's no relevant difference.

Quote:Original post by dmail
That maybe so Steve but I would think the note in LoadLibrary docs over rides that
Quote:
http://msdn.microsoft.com/en-us/library/ms684175.aspx
When specifying a path, be sure to use backslashes (\), not forward slashes (/).
Ah, that's true. I'm not sure why that would be really, forward slashes have always worked for me...
Advertisement
I just moved the LoadLibrary() call to InitInstance() in the main source file, and it seems to be working correctly. Any idea why it won't work in an event handler for a button in a dialog class?
She got a hat and all that hat says is asshole
The problem seems to be sorted now. If I declare the HMODULE variable inside the if statement. It works. Any ideas why?
She got a hat and all that hat says is asshole
Quote:Original post by DOrmisher
The problem seems to be sorted now. If I declare the HMODULE variable inside the if statement. It works. Any ideas why?
If that's your actual code, then it looks to me like your compiler is broken :P I'm assuming you're not using VC6.0, because if you are, be prepared for all sorts of bugs like this.

The only reason I can think it'd fail is if you're changing the current working directory somewhere, and not using a full path properly.
Try to run your program with process monitor (http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) to see what exactly happens when you try to load the dll.

For instance, you should be able to see whether it's because the file was simply not found (in which case you should be able to see the failed open file called by LoadLibrary) or because of some other problem.

This topic is closed to new replies.

Advertisement