[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Attached is a patch which adds that function. It allows putting DLLs
into a sub-folder instead of having to place them near the .exe.
--
Elias Pschernig <elias.pschernig@xxxxxxxxxx>
diff --git a/include/allegro5/allegro_windows.h b/include/allegro5/allegro_windows.h
index 31cdbe0..7964aa4 100644
--- a/include/allegro5/allegro_windows.h
+++ b/include/allegro5/allegro_windows.h
@@ -30,6 +30,7 @@
AL_FUNC(HWND, al_get_win_window_handle, (ALLEGRO_DISPLAY *));
AL_FUNC(bool, al_add_win_window_callback, (ALLEGRO_DISPLAY *, bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM)));
AL_FUNC(bool, al_remove_win_window_callback, (ALLEGRO_DISPLAY *, bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM)));
+AL_FUNC(void, al_set_win_dll_path, (ALLEGRO_PATH *path));
#ifdef __cplusplus
}
diff --git a/include/allegro5/platform/aintwin.h b/include/allegro5/platform/aintwin.h
index 8175389..5f8b867 100644
--- a/include/allegro5/platform/aintwin.h
+++ b/include/allegro5/platform/aintwin.h
@@ -148,6 +148,7 @@ struct ALLEGRO_SYSTEM_WIN
ALLEGRO_DISPLAY *mouse_grab_display; /* May be inaccurate. */
int toggle_mouse_grab_keycode; /* Disabled if zero. */
unsigned int toggle_mouse_grab_modifiers;
+ ALLEGRO_PATH *user_dll_path;
};
/* helpers to create windows */
diff --git a/src/win/wsystem.c b/src/win/wsystem.c
index 535ba77..ef97564 100644
--- a/src/win/wsystem.c
+++ b/src/win/wsystem.c
@@ -21,6 +21,7 @@
#include <ctype.h>
#include "allegro5/allegro.h"
+#include "allegro5/allegro_windows.h"
#include "allegro5/internal/aintern.h"
#include "allegro5/internal/aintern_bitmap.h"
#include "allegro5/internal/aintern_system.h"
@@ -204,6 +205,8 @@ static void win_shutdown(void)
if (using_higher_res_timer) {
timeEndPeriod(1);
}
+
+ al_set_win_dll_path(NULL);
ASSERT(vt);
al_free(vt);
@@ -594,6 +597,18 @@ static bool same_dir(ALLEGRO_PATH *dir1, ALLEGRO_PATH *dir2)
return true;
}
+void al_set_win_dll_path(ALLEGRO_PATH *path)
+{
+ if (_al_win_system->user_dll_path)
+ al_destroy_path(_al_win_system->user_dll_path);
+ _al_win_system->user_dll_path = NULL;
+ if (path) {
+ _al_win_system->user_dll_path = al_clone_path(path);
+ ALLEGRO_INFO("Changed dll loading path to %s\n",
+ al_path_cstr(path, '/'));
+ }
+}
+
static HMODULE maybe_load_library_at_cwd(ALLEGRO_PATH *path)
{
char cwd_buf[MAX_PATH];
@@ -633,6 +648,12 @@ HMODULE _al_win_safe_load_library(const char *filename)
HMODULE lib;
bool msvc_only = false;
+ if (_al_win_system->user_dll_path) {
+ lib = load_library_at_path(_al_win_system->user_dll_path, filename);
+ if (lib)
+ return lib;
+ }
+
/* MSVC only: if the executable is in the build configuration directory,
* which is also just under the current directory, then also try to load the
* library from the current directory. This leads to less surprises when