util/library: Don't mix incompatible parameters

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2021-11-07 07:08:23 +01:00
parent aeb889091e
commit 2ccbd76c02

View file

@ -39,8 +39,11 @@ streamfx::util::library::library(std::filesystem::path file) : _library(nullptr)
#if defined(ST_WINDOWS) #if defined(ST_WINDOWS)
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
auto wfile = ::streamfx::util::platform::utf8_to_native(file.u8string()); auto wfile = ::streamfx::util::platform::utf8_to_native(file.u8string());
_library = reinterpret_cast<void*>( if (file.is_absolute()) {
LoadLibraryExW(wfile.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)); _library = reinterpret_cast<void*>(LoadLibraryExW(wfile.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR));
} else {
_library = reinterpret_cast<void*>(LoadLibraryExW(wfile.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS));
}
if (!_library) { if (!_library) {
DWORD error = GetLastError(); DWORD error = GetLastError();
if (error != ERROR_PROC_NOT_FOUND) { if (error != ERROR_PROC_NOT_FOUND) {