Store paths as UNC or relative to special folder CSIDLs |
As programs become more mobile with the proliferation of laptops and Windows 2000 roaming users, environment settings need to become more flexible. Drive mappings might change often for laptop users who log on to more than one network; a roaming user might use the application from more than one machine with a named folder in a different location.
Coping with this changing environment is actually pretty simple. Instead of storing path information in the registry, read it from the system with APIs like GetTempPath and SHGetFolderPath. If you must store a path, store it as a UNC, or preferably as a path relative to the CSIDL location you are dependent upon. Be aware that relative path information rarely roams well and you should avoid caching it wherever possible.
Avoiding having to save a path is the best solution. Programs can often do this by using the Windows Installer APIs to load components and by building other needed paths on the fly.
System support for SHGetFolderPath is not native on Windows 98, Windows 95, and Windows NT 4.0. These downlevel clients will require the installation of new system files prior to use. (Redistribution specifics not available at press time)
GetTempPath, Registry Functions, SHGetFolderPath, WNetGetUniversalName