I am trying get the parent folder of a Windows user’s profile path. But I couldn’t find any “parameter” to get this using SHGetSpecialFolderPath, so far I am using CSIDL_PROFILE.
Expected Path:
Win7 – “C:\Users”
Windows XP – “C:\Documents and Settings”
With the shell libary version 6.0 you have theThis value was removed (see here), you have to use your own workaround.CSIDL_PROFILES(not to be confused withCSIDL_PROFILE) which gives you what you want.On any prior version you’ll have to implement your own workaround, such as looking for the possible path separator(s), i.e.
\and/on Windows, and terminate the string at the last one. A simple version of this could usestrrchr(orwcsrchr) to locate the backslash and then, assuming the string is writable, terminate the string at that location.Example:
Or of course
GetProfilesDirectory(that eluded me) which you pointed out in a comment to this answer.