The MSDN documentation states
If the function succeeds, the return value is a handle to the module.
If the function fails, the return value is
NULL. To get extended error information, callGetLastError.
while Microsoft support has a list of return values less than 32 that indicate an error
The API function
LoadLibraryloads a DLL and returns either a handle or an error code. If the return value is less than 32, it indicates one of the errors listed below. A return value greater than or equal to 32 indicates success and you should call theFreeLibraryfunction to unload the library.
The second article was last reviewed in 2003 and explicitly applies to Visual Basic 4.0.
What is correct? LoadLibrary returning != 0 or >= 32 for success? Or are both correct and I am missing some hint for a Version difference or a VB specific Windows API wrapper that differs from the C style interface?
LoadLibrary returns NULL on failure. LoadLibrary returns a value less than 32 to indicate failure. KB142814 clearly dates from the 16 bit Windows days, and if you look closely you will see a kb16bitonly keyword. I think it is safe to assume that you are not developing for 16 bit Windows anymore!
Some relevant articles from Raymond Chen on this matter:
The modern day documentation for LoadLibrary is here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175.aspx, that is the first link in your question. It says:
Return value
If the function succeeds, the return value is a handle to the module.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With