Displaying Message Box using .NET Windows Services In Windows 7

一世执手 提交于 2019-12-10 11:25:23

问题


We had a windows service that was used to display a confirmation message box once a user scanned their access card on windows xp but once we migrated to windows 7, that pop up functionality no longer works. Can anyone please guide me through or give me any ideas on how to proceed with fixing this functionality asap?


回答1:


As you have discovered, services now run in session 0 which is a non-interactive session. You cannot interact with the interactive user's desktop in the way that you could in XP.

You have a couple of options:

  1. Call WTSSendMessage to display a message on the interactive desktop. This is fairly basic but may meet your needs. If you really mean ASAP, then this will be the quickest solution.
  2. Run a standard desktop application in addition to your service. Have the service communicate with the desktop app using some form of IPC, for example WCF. When the service wants to display information, send messages to the desktop app over your IPC channel, and let the desktop app display them.



回答2:


In Windows XP, Windows Server 2003, and earlier versions of the Windows operating system, services and applications run in the same session as the one started by the first user who logs onto the console. This session is called Session 0, and as shown in the following image, prior to Windows Vista, Session 0 included both services and standard user applications. Running services and user applications together in Session 0 poses a security risk because services run with elevated privileges, while user applications run with user privileges (most of which are not admin).This makes the services targets for malicious agents that are looking for mechanisms to elevate their own privilege levels by “hijacking” the services.

Starting with Windows Vista, only services are hosted in Session 0. User applications are isolated from services, and run in subsequent sessions created when users log onto the system: Session 1 for the first logged on user, Session 2 for the second, and so on, as shown in the following image.

More details : http://blogs.windows.com/windows/archive/b/developers/archive/2009/10/01/session-0-isolation.aspx

You can find more details -Session 0 Isolation - http://msdn.microsoft.com/en-us/Windows7TrainingCourse_Win7Session0Isolation



来源:https://stackoverflow.com/questions/18528670/displaying-message-box-using-net-windows-services-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!