+// DEFAULT DLL DIRECTORIES
+///////////////////////////////////////////////////////////////////////////////
+
+//Flags
+#define MY_LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x200
+#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
+#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800
+
+#ifdef MUTILS_STATIC_LIB
+#define MY_LOAD_LIBRARY_FLAGS (MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)
+#else
+#define MY_LOAD_LIBRARY_FLAGS (MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS | MY_LOAD_LIBRARY_SEARCH_APPLICATION_DIR)
+#endif
+
+static void set_default_dll_directories(void)
+{
+ typedef BOOL(__stdcall *MySetDefaultDllDirectories)(const DWORD DirectoryFlags);
+ if (const HMODULE kernel32 = GetModuleHandleW(L"kernel32"))
+ {
+ if (const MySetDefaultDllDirectories pSetDefaultDllDirectories = (MySetDefaultDllDirectories)GetProcAddress(kernel32, "SetDefaultDllDirectories"))
+ {
+ pSetDefaultDllDirectories(MY_LOAD_LIBRARY_FLAGS);
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////