Re: Dynamic DLL Loading or Static ?
From: Peter Haas (newsgroupfeedback_at_pjh2.de)
Date: 11/15/03
- Next message: Michael Baytalsky: "Re: How to start default Mail Client?"
- Previous message: Peter Below (TeamB): "Re: Dynamic DLL Loading or Static ?"
- In reply to: Andrew Jameson: "Dynamic DLL Loading or Static ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 Nov 2003 16:09:26 +0100
Hi Andrew,
Andrew Jameson wrote in <3fb614a9$1@newsgroups.borland.com>:
> Loading DLL's ... can someone just give me a good reason for dynamically
> loading them ? (I usually do but I'm not sure why I do !).
First a comment to the used terms. Usually the process is named linking.
A DLL is dynamic linked always: DLL = Dynamic Link Library. The correct
terms are load-time dynamic linking and run-time dynamic linking.
Static linking is e.g. using $L with a lib file.
> To be very much more specific ... I'm using BASS.dll (a 3D Audio DLL).
> I'm experiencing a very, very rare crash on XP systems when I
> initialize this DLL and I'm loading it dynamically. I was wondering
> whether it might be more stable if used static loading.
I can not answer this, I guess, this is dependent of the specific DLL.
>From my sight there should not be any difference, however I know a
example, where a DLL crash always with load-time dynamic linking and
work without problems with run-time dynamic linking. But this was the
only exception, I use load-time dynamic linking with many other DLLs
without a problem.
> Now the other area that I'm not clear on ... a user has Bass.dll (version
> 1.8) in their System folder and I'm relying on Bass.dll(version 2.0) which
> is in my exe folder. With dynamic loading, I'm making a specific reference
> to the file ... what happens in the static load when the user's got 1.8
> loaded ? ( I guess maybe I'm answering my own question ?).
There is a search order to find a DLL with relative path:
1. The directory from which the application loaded.
2. The current directory.
3. The system directory. (GetSystemDirectory)
4. The 16-bit system directory. (not Win9x, WinME)
5. The Windows directory. (GetWindowsDirectory)
6. The directories that are listed in the PATH environment variable.
On WinXP and later:
if HKLM\System\CurrentControlSet\Control\Session
Manager\SafeDllSearchMode is 1 the Sequence is 1, 3, 4, 5, 2, 6.
This is the default value for WinXP SP1 and WinSrv03.
You can change 2. with SetDllDirectory instead of SetCurrentDirectory
without changing the current directory. This API function exists in
WinXP SP1 and WinSrv03.
On Win2k or later:
If there exists a redirection file, the loader ignore any absolute path
values and load the DLL from the application path. A redirection file
have the format appname.local, the contents will be ignored.
Example: Projects.exe -> Project1.exe.local
With other word, it is extrem likely, that the application load the
version 2.0.
Maybe a other application use the version 1.8 at the same time and both
use same resources, what could cause problems.
Bye Peter.
-- JEDI+ API, the active JEDI Header Conversions Project: http://jediplus.pjh2.de
- Next message: Michael Baytalsky: "Re: How to start default Mail Client?"
- Previous message: Peter Below (TeamB): "Re: Dynamic DLL Loading or Static ?"
- In reply to: Andrew Jameson: "Dynamic DLL Loading or Static ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|