[SDL] Dynamically loading SDL dlls
Andre de Leiradella
leiradella at bigfoot.com
Thu Nov 1 17:17:34 PDT 2007
> I don't want to add bloat to their game executable folder, or add
stuff to their system folders, or PATH, etc.
SetEnvironmentVariable only changes the current process' environment.
But you'll have to test if this environment is the one used by
LoadLibrary. I guess it is.
Since your application is already a DLL, you can just put it together
with all other DLLs in a separate folder. Now write another DLL, a small
one that will change the PATH variable and load your "main" DLL using
LoadLibrary. The other DLLs will be automatically loaded when the "main"
DLL is loaded.
This small DLL will have to have proxy functions that will just call
functions of your "main" DLL, whose pointers you'll obtain using
GetProcAddress. I'm assuming that the number of functions of the bot API
is way less than the number of SDL functions you use in your code.
I already tried to LoadLibrary SDL.dll and a few others. I found myself
with loads of GetProcAddress and fighting with macro definitions, and
with the impression that my code would break with the very next SDL release.
Cheers,
Andre
More information about the SDL
mailing list