I'd like to find the directory of the current user profile programmatically in C++.
SHGetSpecialFolderLocation is the best way to get at most of the special paths on Windows. Passed CSIDL_PROFILE
it should retrieve the folder you are interested in.
If you are actually interested in the contents of the %UserProfile% environment variable you could try ExpandEnvironmentStrings
Simplest way on Windows & Linux:
char *szBuff;
szBuff=std::getenv("USERPROFILE"); //Returning value of %USERPROFILE%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With