Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All users path?

Tags:

c++

path

winapi

In C# I can do the following:

DirectoryInfo di = new DirectoryInfo(System.Environment.GetEnvironmentVariable("ALLUSERSPROFILE"));

Which will get me the path to the all users profile.

In C++ I can use the SHGetFolderPath, but it does not seem to have a CSLID for all users. Is there an equlivant function that I can blow the %ALLUSERSPROFILE% out to its path value?

like image 311
Kyle Avatar asked Dec 07 '22 05:12

Kyle


1 Answers

Use SHGetFolderPath with CSIDL_COMMON_APPDATA. Or SHGetKnownFolderPath since Vista with FOLDERID_ProgramData.

Alternatively, use the .NET native Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

like image 88
Kirill V. Lyadvinsky Avatar answered Dec 11 '22 08:12

Kirill V. Lyadvinsky