Is there any API to get the path "C: \ Documents and Settings" on Windows?

Is there any API to get the path: "C: \ Documents and Settings" in C ++ windows?

not: C: \ Documents and Settings \ brianfu \ My Documents.

Many thanks!

Thanks for the luke solution:

GetProfilesDirectory

it works!

+3
source share
4 answers

Prior to Windows Vista, this can be obtained using GetProfilesDirectory () .

In Windows Vista +, this can be done using SHGetKnownFolderIDList()and SHGetKnownFolderPath()using the constant FOLDERID_UserProfiles KNOWNFOLDERID .

+2
source

(% HOMEPATH%), ( ).

+1

It is available with the key ProfilesDirectoryin HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.

(Note that on Win7 (and Vista?) This will C:\Usersnot C:\Documents and Settings.

+1
source

Source: https://habr.com/ru/post/1750463/


All Articles