[This is preliminary documentation and subject to change.]
In a Windows®-based Terminal Server environment, applications should store user-specific information in user-specific locations, separately from global information that applies to all users. This rule applies to information stored in the registry, as well as information stored in files. In general, do not assume that one computer is equivalent to one user.
Store user-specific registry information under the HKEY_CURRENT_USER registry key. Terminal Server loads the current user's personal registry hive into HKEY_CURRENT_USER when the user logs on. Of course, the Terminal Server manages the registry to ensure that each of the logged on clients detects the correct user hive under HKEY_CURRENT_USER.
In contrast, all users share the HKEY_LOCAL_MACHINE hive. Use HKEY_LOCAL_MACHINE to store computer-specific information, not user-specific information.
Store user preference files or other user-specific files in the user's home directory or in a user-specified directory. This consideration applies to temporary files used to store interim information (such as cached data) or to pass data on to another application. User-specific temporary files must also be stored on a per-user basis.
You can use the SHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag to get the location of the user's personal files directory. You can also use the GetWindowsDirectory function to retrieve the path of the Windows directory. In a Terminal Server environment, the Windows directory is guaranteed to be private for each user. Do not store user-specific files under the system directory (for example, WINNT) or program directory (for example, Program Files).