Interacting with the User in a Service

原创 2004年06月24日 14:42:00

For a noninteractive service application to interact with the user, it must open the user's window station ("WinSta0") and desktop ("Default"). By default, only the logged-on user and service applications running in the LocalSystem account are granted access to the user's window station and desktop. This means that services running in other accounts must either impersonate the user when opening the interactive window station and desktop, or have access granted to those accounts by the user.

For compatibility with versions of Windows that support multiple users and/or multiple desktops per user, the user's window station and desktop names should not be hard-coded. Client applications should pass the names of their window station and desktop to the service as part of the request to the service.

This code sample displays a message on the user's desktop in response to an RPC request from one of the user's applications. Note that a global variable dwGuiThreadId in this example is also used in the logoff handling example. If the thread that displays the message box terminates after it is done with the message box, it is not necessary to save and restore the thread's desktop. It is necessary to restore the process's window station.

DWORD dwGuiThreadId = 0;
    LPSTR lpszWindowStation,
    LPSTR lpszDesktop,
    LPSTR lpszText,
    LPSTR lpszTitle,
    UINT fuStyle)
    DWORD dwThreadId;
    HWINSTA hwinstaSave;
    HDESK hdeskSave;
    HWINSTA hwinstaUser;
    HDESK hdeskUser;
    int result;
    // Ensure connection to service window station and desktop, and
    // save their handles.

    hwinstaSave = GetProcessWindowStation();
    dwThreadId = GetCurrentThreadId();
    hdeskSave = GetThreadDesktop(dwThreadId);
    // Impersonate the client and connect to the User's
    // window station and desktop.

    hwinstaUser = OpenWindowStation(lpszWindowStation, FALSE, MAXIMUM_ALLOWED);
    if (hwinstaUser == NULL)
        return 0;
    hdeskUser = OpenDesktop(lpszDesktop, 0, FALSE, MAXIMUM_ALLOWED);
    if (hdeskUser == NULL)
        return 0;
    // Display message box.

    dwGuiThreadId = dwThreadId;
    result = MessageBox(NULL, lpszText, lpszTitle, fuStyle);
    dwGuiThreadId = 0;
    // Restore window station and desktop.

    return result;

AOSP Nougat - "does not have a SELinux domain defined"

AOSP Nougat - "does not have a SELinux domain defined"
  • ztguang
  • ztguang
  • 2017年03月16日 08:48
  • 2293

如何解决User Profile Synchronization Service一直处于“正在启动”状态

前面已经介绍过怎没设置AD域数据同步到SharePoint服务中来, 如果在设置过程遇到User Profile Appication Service无法启动或许可以参考此文章:       在配置...
  • u011355311
  • u011355311
  • 2013年08月08日 19:22
  • 3672

开机登录失败 提示"user profile service服务未能登录,无法加载用户配置文件" 问题解决办法

【问题描述】         Windows系统开机后,在用户登录界面输入密码无法正常登录,提示“user profile service服务未能登录,无法加载用户配置文件”。点击“确定”按钮后又回到...
  • Qidi_Huang
  • Qidi_Huang
  • 2016年09月13日 21:58
  • 34319

User Profile Service服务未能登录问题

电脑重启后,正常输入登录密码,显示User Profile Service服务未能登录,无法加载用户配置文件。确定后再次输入密码依然是同样的问题 解决方法: 一、开机按F8,进入安全模式 二、打...
  • u010393758
  • u010393758
  • 2016年08月20日 09:54
  • 8723


  • dankun6599
  • dankun6599
  • 2018年02月05日 20:50
  • 98

图文SharePoint 2013 中创建、配置、编辑或删除 User Profile Service 应用程序

在 SharePoint Server 2013 中创建、编辑或删除 User Profile Service 应用程序 SharePoint 2013         其他版本      ...
  • jason_dct
  • jason_dct
  • 2016年01月08日 14:25
  • 1514

“User Profile Service 服务未能登录,无法加载用户配置文件” 解决之道

在网上搜索一番后,得到的最简单的解决方法就是:   1、开机按F8 进入到安全模式,登录系统(如果只是标准账户有问题,管理员账户没问题就不要安全模式了 );2、打开注册表,找到带“.bak ”的...
  • Lutx
  • Lutx
  • 2011年01月18日 11:42
  • 12858

Interacting efficiently with a RESTful service with Angular2 and RXJS (Part 3)

In the previous part of the article, we dealt with the way to manage data from a RESTful service a...
  • u011153667
  • u011153667
  • 2016年08月16日 16:39
  • 112

windows平台上配置cygwin错误总结——ERROR: Installing sshd as a service failed!

问题描述: ssh-host-config后出现以下错误信息 Query: Do you want to proceed anyway? (yes/no) yes *** War...
  • joy_91
  • joy_91
  • 2014年04月14日 09:27
  • 2631

SharePoint User Profile Services Application之(一) 创建UPS Service Application

创建User ProfileService Application User Profile Service Application是SharePoint2013的重要组成部分,提供用户属性的同步,...
  • SPFarm
  • SPFarm
  • 2014年12月29日 12:23
  • 1577
您举报文章:Interacting with the User in a Service