How to allow placement of% UserProfile% programmatically in C ++?

I would like to find the directory of the current user profile programmatically in C ++.

+5
source share
3 answers

SHGetSpecialFolderLocation is the best way to access most special paths on Windows. Passed CSIDL_PROFILEit should get the folder you are interested in.

If you're really interested in the contents of the% UserProfile% variable, you can try ExpandEnvironmentStrings

+9
source

The easiest way for Windows and Linux:

char *szBuff;
szBuff=std::getenv("USERPROFILE");  //Returning value of %USERPROFILE%
+4
source

Windows Vista , SHGetKnownFolderPath. - .

+2

All Articles