Skip to content

Commit

Permalink
fix: apply dll load macro to win32api
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiFati committed Jun 23, 2024
1 parent a3a66cd commit 904fcfe
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions win32/src/win32apimodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6263,18 +6263,12 @@ PYWIN_MODULE_INIT_FUNC(win32api)
PyModule_AddIntConstant(module, "VS_FF_PRIVATEBUILD", VS_FF_PRIVATEBUILD);
PyModule_AddIntConstant(module, "VS_FF_SPECIALBUILD", VS_FF_SPECIALBUILD);

HMODULE hmodule = GetModuleHandle(TEXT("secur32.dll"));
if (hmodule == NULL)
hmodule = LoadLibrary(TEXT("secur32.dll"));
if (hmodule != NULL) {
PYWIN_BEGIN_LOAD_LIBRARY("secur32.dll")
pfnGetUserNameEx = (GetUserNameExfunc)GetProcAddress(hmodule, "GetUserNameExW");
pfnGetComputerObjectName = (GetUserNameExfunc)GetProcAddress(hmodule, "GetComputerObjectNameW");
}
PYWIN_END_LOAD_LIBRARY

hmodule = GetModuleHandle(TEXT("kernel32.dll"));
if (hmodule == NULL)
hmodule = LoadLibrary(TEXT("kernel32.dll"));
if (hmodule != NULL) {
PYWIN_BEGIN_LOAD_LIBRARY("kernel32.dll")
pfnGetComputerNameEx = (GetComputerNameExfunc)GetProcAddress(hmodule, "GetComputerNameExW");
pfnGetLongPathNameA = (GetLongPathNameAfunc)GetProcAddress(hmodule, "GetLongPathNameA");
pfnGetLongPathNameW = (GetLongPathNameWfunc)GetProcAddress(hmodule, "GetLongPathNameW");
Expand All @@ -6287,12 +6281,10 @@ PYWIN_MODULE_INIT_FUNC(win32api)
pfnSetDllDirectory = (SetDllDirectoryfunc)GetProcAddress(hmodule, "SetDllDirectoryW");
pfnSetSystemPowerState = (SetSystemPowerStatefunc)GetProcAddress(hmodule, "SetSystemPowerState");
pfnGetNativeSystemInfo = (GetNativeSystemInfofunc)GetProcAddress(hmodule, "GetNativeSystemInfo");
}
PYWIN_END_LOAD_LIBRARY


hmodule = GetModuleHandle(TEXT("user32.dll"));
if (hmodule == NULL)
hmodule = LoadLibrary(TEXT("user32.dll"));
if (hmodule != NULL) {
PYWIN_BEGIN_LOAD_LIBRARY("user32.dll")
pfnEnumDisplayMonitors = (EnumDisplayMonitorsfunc)GetProcAddress(hmodule, "EnumDisplayMonitors");
pfnEnumDisplayDevices = (EnumDisplayDevicesfunc)GetProcAddress(hmodule, "EnumDisplayDevicesW");
pfnChangeDisplaySettingsEx = (ChangeDisplaySettingsExfunc)GetProcAddress(hmodule, "ChangeDisplaySettingsExW");
Expand All @@ -6302,12 +6294,9 @@ PYWIN_MODULE_INIT_FUNC(win32api)
pfnGetMonitorInfo = (GetMonitorInfofunc)GetProcAddress(hmodule, "GetMonitorInfoW");
pfnEnumDisplaySettingsEx = (EnumDisplaySettingsExfunc)GetProcAddress(hmodule, "EnumDisplaySettingsExW");
pfnGetLastInputInfo = (GetLastInputInfofunc)GetProcAddress(hmodule, "GetLastInputInfo");
}
PYWIN_END_LOAD_LIBRARY

hmodule = GetModuleHandle(TEXT("Advapi32.dll"));
if (hmodule == NULL)
hmodule = LoadLibrary(TEXT("Advapi32.dll"));
if (hmodule != NULL) {
PYWIN_BEGIN_LOAD_LIBRARY("Advapi32.dll")
pfnRegRestoreKey = (RegRestoreKeyfunc)GetProcAddress(hmodule, "RegRestoreKeyW");
pfnRegSaveKeyEx = (RegSaveKeyExfunc)GetProcAddress(hmodule, "RegSaveKeyExW");
pfnRegCreateKeyTransacted = (RegCreateKeyTransactedfunc)GetProcAddress(hmodule, "RegCreateKeyTransactedW");
Expand All @@ -6318,7 +6307,7 @@ PYWIN_MODULE_INIT_FUNC(win32api)
pfnRegDeleteTree = (RegDeleteTreefunc)GetProcAddress(hmodule, "RegDeleteTreeW");
pfnRegOpenCurrentUser = (RegOpenCurrentUserfunc)GetProcAddress(hmodule, "RegOpenCurrentUser");
pfnRegOverridePredefKey = (RegOverridePredefKeyfunc)GetProcAddress(hmodule, "RegOverridePredefKey");
}
PYWIN_END_LOAD_LIBRARY

PYWIN_MODULE_INIT_RETURN_SUCCESS;
}

0 comments on commit 904fcfe

Please sign in to comment.