开发者

Why isn't a full file path required to load a dll? In what situation would this functionality be beneficial?

开发者 https://www.devze.com 2023-02-28 11:45 出处:网络
Why doesn\'t Windows require a full file path when calling LoadLibrary, or for CLSIDs w/ registered DLLs, etc. In what situation would someone benefit from having to fall back on the DLL Search Order

Why doesn't Windows require a full file path when calling LoadLibrary, or for CLSIDs w/ registered DLLs, etc. In what situation would someone benefit from having to fall back on the DLL Search Order to find a dll?

I mean, variables such as %SystemRoot% or %ProgramFiles% could get you to the appropriate folder, and .\ would leave you in your current d开发者_运维百科irectory.. So why allow the vagueness?


For explicit linking with GetProcAddress() I would argue that one should use the absolute path to the DLL if at all possible.

For implicit linking with .lib files then the name of the DLL has to be determined at link time which rules out absolute paths.

It is safest to put the DLL in the same directory as the executable, under %Program Files% and protected by UAC, and to use the new DLL search order.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号