GetDllDirectory
produces an ambiguous value. When the string this call produces is empty, it means one of the following:
- nobody has called
SetDllDirectory
- somebody passed
NULL
toSetDllDirectory
- somebody passed an empty string to
SetDllDirectory
The first two cases are equivalent for my purposes, but the third case is a problem. If I want to write save/restore code (call GetDllDirectory
to save the "old" value, SetDllDirectory
to set a "new" value temporarily, and later SetDllDirectory
again to restore the "old" value), I run the risk of reversing some other programmer's intent.
If the other programmer intended for the current working directory to be in the DLL search order (in other words, one of the first two bullets is true), and I pass an empty string to SetDllDirectory
, I will be taking the current working directory out of the DLL search order, reversing the other programmer's intent.
Can anyone suggest an approach to eliminate or work around this ambiguity?
P.S. I know having the current working directory in the DLL search order could be interpreted as a security hole. Nevertheless, it is the default behavior, and my code is not in a position to undo that; my code needs to be compatible with the expectations of all potential callers, many of which are large and old and beyond my control.