Skip to content

LoadLibraryEx() and FreeLibrary() #839

Answered by AArnott
Arebusf21 asked this question in Q&A
Discussion options

You must be logged in to vote

LoadLibraryEx is emitted twice: once with a SafeHandle return type and once with HINSTANCE as its return type. It is only necessary to call FreeLibrary when you use the HINSTANCE returning overload. When you use the SafeHandle overload, you should just dispose of the SafeHandle when you're done with it, and it will call FreeLibrary on your behalf.

The null-throwing issue you found is a bug in the metadata, which I've reported for you in microsoft/win32metadata#1421.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Arebusf21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants