PDA

View Full Version : Windows user directory from Borland C++


NuriumGames
01-03-2005, 04:13 AM
This should be an easy one, but can't find it :confused:

How do you get the data user directory in windows (i.e. C:\Documents and Settings\UserName\Program Data )

Thanks

oNyx
01-03-2005, 05:37 AM
CString UserDir(CString& Path)
{
CRegKey key;
char buffer[256];
DWORD dwCount = sizeof( buffer);
key.Open( HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Expl orer\\Shell Folders", KEY_READ);
key.QueryValue( buffer, "AppData", &dwCount);
key.Close();

Path = buffer;
return Path;
}

That's for the "AppData" folder. I suggest to start regedit and check the other keys if you want something different.

edit: no idea why the forum tears "Explorer" apart.

NuriumGames
01-03-2005, 05:49 AM
Thanks oNyx :)