?/TD> |
Microsoft DirectX 9.0 |
This topic contains tips for using Microsoft?DirectX?on Microsoft Windows?XP.
Windows XP allows multiple users to be logged on to one computer at the same time. If your application cannot run multiple instances simultaneously, you should check to see if another instance is running before starting a new instance. You cannot use FindWindow across desktop sessions. FindWindow only works within the current session.
To see if an instance of the application is already running, use a global mutex. If an instance is running, you can use FindWindow to see if the instance is in the current session and restore the window. Otherwise, notify users that they cannot use the application.
Fast User Switching allows users to switch between sessions. Users do not have to terminate their applications or log out for another user to start a session. Instead, they use Fast User Switching, which enables another user to log on and work on the computer.
DirectX applications should be prepared to handle this situation. Windows will send out a WM_WTSSESSION_CHANGE message when a user session changes. In order to receive this message, your application must register its window handle by calling WTSRegisterSessionNotification.
There are two types of users on Windows XP: administrators and limited users. Administrators have read/write access to all of the hard drive. Limited users are restricted to a few areas of the hard drive where they can write data.
The only areas of the hard drive that limited users have write access to, and therefore the only place DirectX applications should store information for limited users, are the following (default) directories:
CSIDL value | Folder |
---|---|
CSIDL_COMMON_DOCUMENTS | C:\Documents and Settings\All Users\Documents |
CSIDL_PERSONAL | C:\Documents and Settings\<username>\MyDocuments |
CSIDL_COMMON_APPDATA | C:\Documents and Settings\All Users\Application Data |
CSIDL_LOCAL_APPDATA | C:\Documents and Settings\<username>\Application Data |
Because installation should be to the Program Files directory (CSIDL_PROGRAM_FILES) by default, only an administrator can install an application. If a limited user is trying to install an application, an informational message box should be displayed telling the user that they need administrator privileges to install.
All of these locations should be determined by passing the appropriate CSIDL to the SHGetFolderPath function, rather than being hard-coded.
Data files generated by an application should be stored with limited users in mind. Use the following table to determine where to store the data.
Data available for: | CSIDL value | Can user load, view, and alter data? | Example |
---|---|---|---|
All users | CSIDL_COMMON_APPDATA | NO | System configuration |
Current user | CSIDL_LOCAL_APPDATA | NO | Keyboard bindings |
All users | CSIDL_COMMON_DOCUMENTS | YES | Shared saved files |
Current user | CSIDL_PERSONAL | YES | Private saved files |
To correctly store data in the registry, use the following guidelines.
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER