16struct AutoLoadSystemDependencies
18 AutoLoadSystemDependencies()
24 HMODULE
module = ::GetModuleHandleW(L
"kernel32.dll");
30 decltype(SetDefaultDllDirectories)* setDefaultDllDirectories =
31 (
decltype(SetDefaultDllDirectories)*) GetProcAddress(module,
"SetDefaultDllDirectories");
32 if (setDefaultDllDirectories)
34 setDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
43#ifdef HAVE_64BIT_BUILD
47 static LPCWSTR delayDLLs[] = { L
"apphelp.dll",
63 static LPCWSTR delayDLLs[] = { L
"apphelp.dll",
84 WCHAR systemDirectory[
MAX_PATH + 1] = { L
'\0' };
87 GetSystemDirectoryW(systemDirectory, MAX_PATH + 1);
88 size_t systemDirLen = wcslen(systemDirectory);
91 if (systemDirectory[systemDirLen - 1] != L
'\\' && systemDirLen)
93 systemDirectory[systemDirLen] = L
'\\';
99 for (
size_t i = 0;
i <
sizeof(delayDLLs) /
sizeof(delayDLLs[0]); ++
i)
101 size_t fileLen = wcslen(delayDLLs[i]);
102 wcsncpy(systemDirectory + systemDirLen, delayDLLs[i],
103 MAX_PATH - systemDirLen);
104 if (systemDirLen + fileLen <= MAX_PATH)
106 systemDirectory[systemDirLen + fileLen] = L
'\0';
112 LPCWSTR fullModulePath = systemDirectory;
115 LoadLibraryExW(fullModulePath,
nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);