Windows中的桌面管理 Process Connection to a Window Station

来源:互联网 发布:中文域名多少钱一年 编辑:程序博客网 时间:2024/05/21 10:53

A process automatically establishes a connection to a window station and desktop when it first calls a USER32 or GDI32 function (other than the window station and desktop functions). The system determines the window station to which a process connects according to the following rules:

 

进程在调用第一个USER32或GDI32函数时,自动连接到一个Window Station和Desktop。系统按照如下规则决定进程连接到哪个Window Station:

 

  1. If the process has called the SetProcessWindowStation function, it connects to the window station specified in that call.
    如果进程已经调用SetProcessWindowStation 函数,指定了Window Station。
  2. If the process did not call SetProcessWindowStation, it connects to the window station inherited from the parent process.
    如果进程没有调用SetProcessWindowStation  ,进程将继承父进程连接到的Window Station。
  3. If the process did not call SetProcessWindowStation and did not inherit a window station, the system attempts to open for MAXIMUM_ALLOWED access and connect to a window station as follows:

    如果进程未调用SetProcessWindowStation  并且也没有继承Window Station,系统尝试MAXIMUM_ALLOWED访问权限打开并连接到下面的Window Station。

    • If a window station name was specified in the lpDesktop member of the STARTUPINFO structure that was passed to the CreateProcess function when the process was created, the process connects to the specified window station.
      调用CreateProcess  时,为STARTUPINFO  参数中的lpDesktop  属性指定了Window Station名称。
    • Otherwise, if the process is running in the logon session of the interactive user, the process connects to the interactive window station.
      否则,进程的Widnow Station运行在交互用户登录会话的交互Window Station中。
    • If the process is running in a noninteractive logon session, the window station name is formed based on the logon session identifier and an attempt is made to open that window station. If the open operation fails because this window station does not exist, the system tries to create the window station and a default desktop.
      如果进程运行在非交互登录会话中,Windows Station 名称的形成以登录会话标识为基础,并且尝试打开这个Window Station。如果打开操作因为Window Station不存在而失败,系统将尝试创建一个Window Station和一个Default Desktop。

The window station assigned during this connection process cannot be closed by calling the CloseWindowStation function.

 

Window Station 在进程连接的过程中,不能通过调用CloseWindowStation  关闭。

 

When a process is connecting to a window station, the system searches the process's handle table for inherited handles. The system uses the first window station handle it finds. If you want a child process to connect to a particular inherited window station, you must ensure that the only the desired handle is marked inheritable. If a child process inherits multiple window station handles, the results of the window station connection are undefined.

Handles to a window station that the system opens while connecting a process to a window station are not inheritable.

 

 当进程连接到一个Window Station后,系统查询进程句柄表找到继承的句柄。系统使用第一个找到的Window Station。如果子进程想连接到一个指定的继承Window station,必须确认仅继承了想要的那个句柄。如果子进程继承了多个Window Station句柄,则连接未被接受。系统在进程连接时打开的Window Station句柄是不可继承的。

原创粉丝点击