If I do LoadLibrary("%windir%\\\\system32\\\\ole32.dll")
does that mean Windows will ONLY load from "c:\\windows\\system32\\ole32.dll" ? Also does LoadLibrary() in C understand the environment variable?
as Serge said and carefully tested, LoadLibrary does not do environment variable substitution in path.
however, there is a function in the windows API to replace environment variables in strings: ExpandEnvironmentStrings()
. you can perform the required substitution on your path before calling LoadLibrary()
.
The docs for LoadLibrary clearly state that:
If the string specifies a full path, the function searches only that path for the module.
That said, they don't mention support for environment variables substitution. I seriously doubt they do support environment variables substitution: That's a shell feature, not a kernel API one.
BTW, that means LoadLibrary()
would consider %windir%\\blah.dll
as a relative path since it doesn't start with a drive letter or a UNC path. Hence it would look through the whole series of directories, looking for a subdir named %windir%
, which it's not likely to find!
I gave it a quick test: It confirms my opinion. Error = 126 : The specified module could not be found .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.