Microsoft Windows XP Shared Environment: User Accounts and Quick User Switching
March 2001 Abstract: This article introduces several features of Microsoft Windows XP, including multi-user accounts, fast users switching, and remote desktops. Directory Introduction Quick User Switch Remote Desktop Requirements and Structure New Session Switch Messages Make sure that only one version of the application is running the application, the system is interacting with other issues. Whether you are aimed at Microsoft® Windows® XP Home Edition or Write an application for Windows XP Professional? Remember: Windows XP (in the beta version "WHISTLER") is a personal system, that is, each computer user will get a separate Windows XP account. In a business environment, multiple users can access their own emails on the same computer, and have full access to their respective documents and settings. In families using Home Edition, each family member can get a separate account. This is different from Microsoft Windows 95 and Windows 98, because all members of the family usually have an account in the original two systems. The user is best to create these accounts during the setup process, but you can also create these accounts later using the Control Panel later. These accounts are based on Windows 2000 profiles, which means that the data of each user is separated from each other. By default, these accounts are not received by password, but users can choose to set the password for the account. If you have multiple accounts on your computer, a Welcome screen is displayed. On the Welcome screen, each user will get a separate graph, and log in to the computer by clicking the graph. Quick User Switching Windows XP has launched a fast user switching feature. In Windows XP, when other users want to access their accounts, the current user does not have to log out from the computer. Instead, the user account can always remain login, and multiple users can quickly switch between all open accounts. Multiple accounts can be opened at the same time on a computer. For example, after the father goes home, start using his computer. He opened Microsoft® PowerPoint® to start processing a document. At this time, the son Billy came over and used a computer. Billy Go to the "Welcome" screen, log in to the computer by clicking the Billy graph, then starting playing games. At this time, the father has not yet been logged out. If you need it, your father can also come back to switch to his already opened account and do not need Billy to log out. The father's PowerPoint demo document is still open, and his Internet connection has not been disconnected. In the business environment, if the father needs to complete the job quickly, he can easily use the user to share the same computer in different classes through the user, even if their shifts overlap. Remote Desktop Access Windows XP also has a remote desktop feature that allows users to access data and applications from other computers. On a business workstation, Windows XP enables users to access their desktops from a remote computer. For example, the mother can lock the office workstation and connect to the office workstation after home. Household computers can run from the remote control office workstation. When the mother returns to the office, she can release the desktop lock and continue to complete the work that is not finished at home. For example, you have to handle multiple sales accounts on your trip, and you want to check the contract text you store in the Office Computer "My Document" folder. You stopped in a branch of the company and borrowed a computer. You can open your own account (including all your documents and settings) and find the desired contract.
Requirements and Structure Fast User Switching and Remote Desktops Using Terminal Services Technology without any changes, they can be used for most earlier versions of Microsoft® Win32® applications. Windows XP does not need to switch the user to write new code, but only need to write good code. If your application passes the Windows 2000 application authentication program, and you implement basic configuration file separation and power management feature, the application should be able to run normally in Windows XP. Note: Use several new messages, you can better run your application in the Windows XP system. These messages will be described later in this article. The infrastructure provided by Windows 2000 is included in all versions of Windows XP (including Professional version and Home Client). This structure supports the status of user data, user settings, and computer settings. Applications that use this structure will provide the following benefits: users can easily back up separate documents and settings without backing up applications and operating system files. As mentioned above, multiple users can share the same computer and maintain their preferences and settings. In addition, a user can also use multiple computers, and can be maintained from one computer documents and settings for another computer. It is quite simple, you only need:
The default is the data created in the "My Document" folder. Correctly classify and store application data. Reduce the "Access Rejected" tips. New session switching messages are usually, when performing session switching, there is no need to notify the application. However, if the application needs to know the time when the desktop is in the current state, the registration session switching notification is available. This feature should be selected if the application accesses a serial port or other shared resource on your computer. To register notifications, use the following functions in WTSAPI32.H: BOOL WINAPI
WTSREGISTERCONSOLENOTIFICATION
HWND HWND, // WINDOW handle
DWORD dwflags // logo
);
The registered HWND receives the message WM_WTSSession_Change in dwflags, you can specify: notify_for_this_session - Notifications only to the window will affect the session changing events of the session. Notify_for_all_sessions - Notify all sessions changing events to the window. This session can be found in the WPARAM code, which may contain one of the following signs: WTS_CONSOLE_CONNECT
WTS_CONSOLE_DISCONNECT
WTS_REMOTE_CONNECT
WTS_REMOTE_DISCONNECT
LPARAM contains the session ID of the affected session. If your process no longer needs these notifications or termination, you should call to cancel the notification registration. Bool WinApi
WTsunRegisterconsolenotification
HWND HWND / / WINDOW handle.
);
The hWnd value passed to the WTSREGisterConsolenotification is counted in a reference, so WTSREGISTERCONSOLENOTIFICATION must be called in the same number of call wtsregisterconsolenotification. The application can use the WM_WTSSession_Change message to track its status and release or get a console-specific resource. Make sure that only one version of the application is run for many applications, you must ensure that only one routine of the application is run. In Windows XP, there are several ways to achieve this.
Use FindWindow or FindWindowEx to search the window to open. If the window is turned on, use FindWindow or FindWindowEx to determine that the application is turned on. When you open an application, create a mutex or signal, then turn it off when the application exits. The global object namespace will be separated for each desktop to produce a unique mutual exclusive logo and a list of signals. The system service interaction From a programming point of view, it takes two cases to discuss. The server process receives the direct request of the client process. In this case, the message may be transmitted via the LPC or RPC. Whether it is by LPC or RPC, the client token is obtained by the API. Once the client token is obtained, the server can call Advapi32! CreateProcessasuser. Assume that the client user token has session tags (which should be said), will call the process in the correct window station. Note: Advapi32! CreateProcessasuser does not currently support handle inheritance between the sessions. The server process receives some form of notifications, requiring the user interface, but it does not have to be in the current user's environment. In this case, the server process can copy its primary process token and change the session identifier to the current session identifier. To retrieve the session ID of the current session on the console, use the public API WTSGetActiveConsolesSionID (). Note: In order to set the token session ID, you need to have SE_TCB_PRIVILEGE. It can only be used as a service running in NT Authority / System. Other issues do not create a mapping file in a central location (such as Windows Directory) that is not particularly confirmed. Temporary files, memory maps and documents should be stored in the corresponding subdirectory of the user profile directory. You can use ShGetFolderLocation or SHGETFolderPath to find the appropriate file storage location. If CSIDL_APPDATA is passed to the application, the file system directory is returned, which is used as a public repository for the application-specific data. CSIDL_LOCAL_APPDATA should be used to change data with the user's changes, such as temporary files. When the remote desktop function is added, the application must not use the required bandwidth. When the desktop is remotely connected, the application should avoid using a large number of screen drawings and animation effects. The user desktop can be dynamically switched during remote and console. The application should use the above WM_WTSSession_Change message to perform synchronization with the local connection status.