Get the home path (%HOMEPATH% environment variable), and then go one folder up (removing the user name).
Patrick
2010-06-17 10:21:11
Get the home path (%HOMEPATH% environment variable), and then go one folder up (removing the user name).
It's available via the ProfilesDirectory key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.
(Note that on Win7 (and Vista?) this will be C:\Users not C:\Documents and Settings.
Prior to Windows Vista, this can be retrieve via GetProfilesDirectory().
In Windows Vista+, this can be done via the SHGetKnownFolderIDList() and SHGetKnownFolderPath() functions using the FOLDERID_UserProfiles KNOWNFOLDERID constant.