请介绍一下怎样利用CreateDesktop来创建自己的桌面,如果有实例代码更好。

解决方案 »

  1.   

    The CreateDesktop function creates a new desktop on the window station associated with the calling process. It retrieves a handle that can be used to access the new desktop. The calling process must have an associated window station, either assigned by the system at process creation time or set by SetProcessWindowStation. A desktop is a secure object contained within a window station object. A desktop has a logical display surface and contains windows, menus, and hooks.
    HDESK CreateDesktop(
      LPCTSTR lpszDesktop,
      LPCTSTR lpszDevice,
      LPDEVMODE pDevmode,
      DWORD dwFlags,
      ACCESS_MASK dwDesiredAccess,
      LPSECURITY_ATTRIBUTES lpsa
    );Parameters
    lpszDesktop 
    [in] Pointer to a null-terminated string specifying the name of the desktop to be created. Desktop names are case-insensitive and may not contain backslash characters (\). 
    lpszDevice 
    Reserved; must be NULL. 
    pDevmode 
    Reserved; must be NULL. 
    dwFlags 
    [in] This parameter can be zero or the following value. Value Meaning 
    DF_ALLOWOTHERACCOUNTHOOK Enables processes running in other accounts on the desktop to set hooks in this process. dwDesiredAccess 
    [in] Access to the desktop. For a list of values, see Desktop Security and Access Rights. 
    This parameter must include the DESKTOP_CREATEWINDOW access right, because internally CreateDesktop uses the handle to create a window.lpsa 
    [in] Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited. 
    The lpSecurityDescriptor member of the structure specifies a security descriptor for the new desktop. If this parameter is NULL, the desktop inherits its security descriptor from the parent window station.Return Values
    If the function succeeds, the return value is a handle to the newly created desktop. If the specified desktop already exists, the function succeeds and returns a handle to the existing desktop. When you are finished using the handle, call the CloseDesktop function to close it.If the function fails, the return value is NULL. To get extended error information, call GetLastError.Res
    The CreateDesktop function returns a handle that can be used to access the desktop.If the dwDesiredAccess parameter specifies the READ_CONTROL, WRITE_DAC, or WRITE_OWNER standard access rights, you must also request the DESKTOP_READOBJECTS and DESKTOP_WRITEOBJECTS access rights.