Does LoadLibrary load NULL or error code <32 on failure?

MSDN documentation contains

If the function succeeds, the return value is a handle to the module.

If the function does not work, the return value NULL. For extended error information, call GetLastError.

while Microsoft support contains a list of return values ​​less than 32 that indicate an error

The API function LoadLibraryloads the 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 must call the function FreeLibraryto unload the library.

The second article was last reviewed in 2003 and is explicitly applied to Visual Basic 4.0.

What is right? LoadLibraryreturns != 0or >= 32for success? Either both are correct, and I miss a hint of a version difference or a special Windows API shell other than the C style interface.

+3
source share
1 answer
  • On 32-bit and 64-bit Windows LoadLibraryreturns NULLon failure.
  • On 16-bit Windows LoadLibrary, a value of less than 32 is returned to indicate a failure.

KB142814 clearly dates from the 16-bit days of Windows, and if you look closely, you will see the kb16bitonly keyword. I think it is safe to assume that you are no longer developing for 16-bit Windows!

:

LoadLibrary : https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175.aspx, . :

, .

, NULL. , GetLastError.

+7

All Articles