Page 1 of 1

Windows Home Directory

Posted: Tue Jun 03, 2003 8:13 am
by sonneveld
What's a decent algorithm for discovering the Windows home directory? I'm trying to figure some stuff out for NAGI but I want to be able to find the Windows equivalent of the unix directories

.../game <-- this will be passed to NAGI, easy
~/ <-- documents and settings? what if it's changed.. what about windows 95?
/etc <-- documents and settings? this is for more global settings though.
.../nagi <-- nagi will know this. these would store default settings.

Any suggestions? I need a decent system that will work for Win 95, 98, ME, NT, 2k, XP.. etc etc :) Would I be correct in assuming for later versions of windows I can use the enviroment settings but earlier versions I need to fudge something togeher?

- Nick

Re:Windows Home Directory

Posted: Tue Jun 03, 2003 1:36 pm
by df
just abstract an interface out for it.

on win32 you have standard api calls for things likle WinGetSystemDirectory, WinGetWindowsDirectory, WinGetTempFileAndPath (handy!).

on unix you have to manually parse ~, its not done on the system level.

also remember the 'My Documents/Documents and Settings' are special folders whose locations can change (reg entries). best bet is to use the environment vars for this.
those folders was all different between 95/95, nt4, 2k+xp. so you have 3 different locations (if user didnt change location in registry). also 95/98 doesnt have a concepct of multiuser so....

Re:Windows Home Directory

Posted: Tue Jun 03, 2003 6:00 pm
by sonneveld
Actually, even with Windows 95, you can have multiple profiles.. i might have to google harder.

- Nick

Re:Windows Home Directory

Posted: Tue Jun 03, 2003 6:11 pm
by Tim
On current versions of Windows (2000 and XP), this is easily resolved. On previous versions a little guesswork is involved.

SHGetSpecialFolderLocation, SHGetFolderLocation and SHGetSpecialFolderPath can be used with various path constants. On current Windows you can query for the location of the CSIDL_COMMON_APPDATA and CSIDL_APPDATA folders, which should be used for application data for all users and for the current user respectively. CSIDL_APPDATA is probably the closest you'll have to a ~ directory on Windows, but it's not supported on a system that doesn't have the desktop update installed (i.e. Windows 95 and NT 4).

Re:Windows Home Directory

Posted: Tue Jun 03, 2003 7:08 pm
by sonneveld
Anyone had much experience with this library?

http://www.maccormack.net/~djm/fnkdat/

seems to be able to do most of this stuff.

- Nick