Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate paths with environment variables (Eg. %temp%)

Tags:

c++

winapi

I am searching for a winapi function to expand paths with environment variables. I have tried GetFullPathName but the result is weird: "%appdata%\something" becomes "C:\<path to directory of exe>\%appdata%\something".

How to do this correctly?

like image 680
Zotta Avatar asked Oct 03 '11 23:10

Zotta


2 Answers

Try ExpandEnvironmentStrings.

like image 154
Raymond Chen Avatar answered Oct 05 '22 23:10

Raymond Chen


Cause I needed it with C#/.NET: Environment.ExpandEnvironmentVariables Method

I hope it'll help somebody.

like image 29
gimbar Avatar answered Oct 05 '22 23:10

gimbar