mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
...
This commit is contained in:
parent
89ec12cada
commit
c55bb4b8af
@ -12,29 +12,23 @@ static dylib_entry_t load_dylib(const char* path){
|
|||||||
auto p = std::filesystem::absolute(path, ec);
|
auto p = std::filesystem::absolute(path, ec);
|
||||||
if(ec) return nullptr;
|
if(ec) return nullptr;
|
||||||
HMODULE handle = LoadLibraryA(p.string().c_str());
|
HMODULE handle = LoadLibraryA(p.string().c_str());
|
||||||
// get last error
|
if(!handle){
|
||||||
// Get the last error code
|
DWORD errorCode = GetLastError();
|
||||||
SetErrorMode(SEM_FAILCRITICALERRORS);
|
// Convert the error code to text
|
||||||
DWORD errorCode = GetLastError();
|
LPSTR errorMessage = nullptr;
|
||||||
|
FormatMessageA(
|
||||||
// Convert the error code to text
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
LPSTR errorMessage = nullptr;
|
nullptr,
|
||||||
FormatMessageA(
|
errorCode,
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
||||||
nullptr,
|
(LPSTR)&errorMessage,
|
||||||
errorCode,
|
0,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
nullptr
|
||||||
(LPSTR)&errorMessage,
|
);
|
||||||
0,
|
printf("%lu: %s\n", errorCode, errorMessage);
|
||||||
nullptr
|
LocalFree(errorMessage);
|
||||||
);
|
return nullptr;
|
||||||
|
}
|
||||||
// Print the error message to stdout
|
|
||||||
printf("%lu: %s\n", errorCode, errorMessage);
|
|
||||||
|
|
||||||
// Free the message buffer
|
|
||||||
LocalFree(errorMessage);
|
|
||||||
if(!handle) return nullptr;
|
|
||||||
return (dylib_entry_t)GetProcAddress(handle, "platform_module__init__");
|
return (dylib_entry_t)GetProcAddress(handle, "platform_module__init__");
|
||||||
}
|
}
|
||||||
#elif PK_SUPPORT_DYLIB == 2
|
#elif PK_SUPPORT_DYLIB == 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user