make an interactive windows service

后端 未结 1 1408
滥情空心
滥情空心 2021-01-25 19:56

I want my Java application to be an interactive windows service (a windows service that has GUI when the user is logged in).

I searched for this and I see that the way t

相关标签:
1条回答
  • 2021-01-25 20:06

    Prior to Windows Vista, all services and application were run in the same session. This provided the convenience of allowing Windows services to have front-facing UIs and interacting with users directly, but it also posed a security risk. For example, a Windows service that runs with elevated user privileges (e.g., admin rights) could potentially be compromised through exploits of the UI.

    Beginning with Windows Vista, Windows services are isolated in Session 0 while all user logins and applications are run in other sessions. Technically, Windows services can still interact with the desktop via Session 0, but ordinary users have no convenient way of accessing Session 0. So while your Windows service can pop up a confirmation dialog box, the user will never see it because it displays in the Session 0 desktop. Further, the user will be unable to confirm the dialog, meaning that the Windows service remains "stuck."

    In short, having your Windows service interact with the desktop is no longer feasible. You'll have to create the Windows service and then a front-end application and provide some means for them to communicate, e.g., pipes, sockets, shared memory, etc. The recommended way to do this in .NET is to use the Windows Communication Foundation (WCF). I'm not sure how easy this is to do w/ Java, and in the spirit of full disclosure, I use sockets myself.

    HTH

    0 讨论(0)
提交回复
热议问题