Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LoadLibrary parse environment variables such as %windir%

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?

like image 701
unixman83 Avatar asked Sep 13 '11 17:09

unixman83


People also ask

How can I see Environment Variables in CMD?

On WindowsSelect Start > All Programs > Accessories > Command Prompt. In the command window that opens, enter set. A list of all the environment variables that are set is displayed in the command window.

How do I view Environment Variables in .NET core?

Open project properties by right clicking on the project in the solution explorer and select Properties. This will open properties page. Click on Debug tab and you will see Environment Variables as shown below. You may change the value as per your need.

What are Windows Environment Variables?

An environment variable is a dynamic "object" on a computer, containing an editable value, which may be used by one or more software programs in Windows. Environment variables help programs know what directory to install files in, where to store temporary files, and where to find user profile settings.

How do I get Environment Variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.


1 Answers

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().

like image 79
Adrien Plisson Avatar answered Sep 20 '22 09:09

Adrien Plisson