Windows Home Directory

Programming, for all ages and all languages.
Post Reply
sonneveld

Windows Home Directory

Post 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
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Windows Home Directory

Post 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....
-- Stu --
sonneveld

Re:Windows Home Directory

Post by sonneveld »

Actually, even with Windows 95, you can have multiple profiles.. i might have to google harder.

- Nick
Tim

Re:Windows Home Directory

Post 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).
sonneveld

Re:Windows Home Directory

Post 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
Post Reply