-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Inside a method that returns a HINSTANCE, the returning null value has to be explicitly cast to an HINSTANCE: (HINSTANCE)0 .
public unsafe static HINSTANCE LoadLibraryFromSystemPathIfAvailable(string libraryName)
{
if (GetModuleHandle(Libraries.Kernel32) == 0)
{
return (HINSTANCE)0;
}
// LOAD_LIBRARY_SEARCH_SYSTEM32 was introduced in KB2533623. Check for its presence
// to preserve compat with Windows 7 SP1 without this patch.
fixed (char* lpLibFileName = libraryName)
{
HINSTANCE result = LoadLibraryEx(lpLibFileName, (HANDLE)0, LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_SEARCH_SYSTEM32);
if (result != 0)
{
return result;
}
// Load without this flag.
if (Marshal.GetLastWin32Error() != ERROR.INVALID_PARAMETER)
{
return (HINSTANCE)0;
}
return LoadLibraryEx(lpLibFileName, (HANDLE)0, 0);
}
}Describe the solution you'd like
A null value for HINSTANCE, such as:
HINSTANCE.NullMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request