Is there an easy way to translate a path with system path variables to an absolute path?
So %ProgramFiles%\Internet Explorer\hmmapi.dll
becomes C:\Program Files\Internet Explorer\hmmapi.dll
I like to know if there is an API call that can do this, or do I have to do this the hard way and detect %..% sequences and replace them with the corresponding environment variable?
You can determine the absolute path of any file in Windows by right-clicking a file and then clicking Properties. In the file properties first look at the "Location:" which is the path to the file.
Select Start select Control Panel. double click System and select the Advanced tab. Click Environment Variables. In the section System Variables find the PATH environment variable and select it.
To list ALL the environment variables and their values, start a CMD and issue the command " set ", as follows, // Display all the variables (in NAME=VALUE pairs) set COMPUTERNAME=xxxxxxx OS=xxxxxxx PATH=xxxxxxx ....... Try issuing a " set " command on your system, and study the environment variables listed.
In the Environment Variables window (as shown below), highlight the Path variable in the System Variable section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
You can use the WinAPI function ExpandEnvironmentStrings
:
function ExpandEnvStr(const szInput: string): string;
const
MAXSIZE = 32768;
begin
SetLength(Result,MAXSIZE);
SetLength(Result,ExpandEnvironmentStrings(pchar(szInput),
@Result[1],length(Result)) - 1);
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With