?/TD>
Microsoft DirectX 9.0

DirectX and Windows XP


This topic contains tips for using Microsoft?DirectX?on Microsoft Windows?XP.

Handling Multiple Users

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

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.

Note  Microsoft DirectDraw?and Microsoft Direct3D?applications that set the window to full screen by default will not allow Fast User Switching.

File Storage

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 valueFolder
CSIDL_COMMON_DOCUMENTSC:\Documents and Settings\All Users\Documents
CSIDL_PERSONALC:\Documents and Settings\<username>\MyDocuments
CSIDL_COMMON_APPDATAC:\Documents and Settings\All Users\Application Data
CSIDL_LOCAL_APPDATAC:\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 valueCan user load, view, and alter data?Example
All usersCSIDL_COMMON_APPDATANOSystem configuration
Current userCSIDL_LOCAL_APPDATANOKeyboard bindings
All usersCSIDL_COMMON_DOCUMENTSYESShared saved files
Current userCSIDL_PERSONALYESPrivate saved files

Note  If the user is meant to load, view, and alter data, ensure that there is a file association and icon representative to the application.

Registry Storage

To correctly store data in the registry, use the following guidelines.



© 2002 Microsoft Corporation. All rights reserved.