Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gimp

[Win32] Loading DLL's from a different directory

This topic is 5914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''d like to be able to implicitly load a DLL from a directory not in the system path. Reason for this is as follows: Directories: \Game \Game\Sound I load Sound.dll using GetProcAddress. Sound.dll is my DLL. It works fine. However, sound.dll implicitly links in fmod.dll. Run game and I get an error, fmod.dll cannot be found, it''s sitting in Sound.dll. Now since fmod.dll is beinf implicitly loaded in to the address space of sound.dll I''d have spected it to be a ''current directory'' however this doesn''t seem to be the case. Is there a way around this. I love structure and I''ve love to put my DLL where I want them. Is there a way to ''add'' a directory to the system path while my app is running perhaps? Chris Brodie http:\\fourth.flipcode.com

Share this post


Link to post
Share on other sites
Advertisement
If you have MSVC, you can delay-load your DLLs and override the hook proc to manually load fmod.dll if it can''t be found in the default search path.

Share this post


Link to post
Share on other sites
quote:

Now since fmod.dll is beinf implicitly loaded in to the address space of sound.dll I''d have spected it to be a ''current directory'' however this doesn''t seem to be the case.



sound.dll does not have it''s own address space. Only processes have their own address space.

Where is fmod.dll located? It needs to be in one of the search paths used by Windows or in the same directory as your app (the same directory as sound.dll may also be ok but I''m not sure about that).

Share this post


Link to post
Share on other sites
and thats the problem. fmod.dll is in the same directory as Sound.dll and it is not found. fmod is only found when it''s in the same directory as the exe(I won''t even bother with anywhere else in the path).

Is there any way around this?

Chris Brodie
http:\\fourth.flipcode.com

Share this post


Link to post
Share on other sites
I'd put both DLL's in \Game\Sound and add \Game\Sound to the PATH enviroment variable.

Adding the path to the PATH variable while the program is running is not going to work since the DLL's are mapped before execution is passed to your entry point.

You could try creating a small 'startup' program that adds the path (if not already there) and then launches your app, or create an install package.

You can use putenv and getenv to add/edit enviroment variables

[edited by - Solo on June 5, 2002 11:32:27 AM]

[edited by - Solo on June 5, 2002 11:36:15 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
LoadLibraryEx with the LOAD_WITH_ALTERED_SEARCH_PATH flag when you load sound.dll

Is that make sense?

Share this post


Link to post
Share on other sites
Oops, I forgot that sound.dll was being loaded explicitly so scratch that part about the DLL''s being loaded before execution is passed to your entry point.

Share this post


Link to post
Share on other sites
Solo,

You got it. _putenv seems to work just the way I want. When I load Sound\Sound.dll I grab the relative path, add it to the current path eg c:\game\mygame\sound\ and add that to the PATH environment variable. That way a componenet I load will have access to DLL''s it needs.

Works great!


Chris Brodie
http:\\fourth.flipcode.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!