简体   繁体   English

Windows 服务 Win10 中的 Toast 通知

[英]Toast Notification in Windows Service Win10

Im developing a software and im considering it as a Service because i need it to listen to ports 24X7 and notify when new client got connected(Toast Notification).我正在开发一个软件并将其视为一项服务,因为我需要它来监听端口 24X7 并在新客户端连接时通知(Toast 通知)。 I was able to send Toast notification from classic Win32 c++ application but i can't send it through Windows Service even when i check 'Allow Service to Interact with UI'.我能够从经典的 Win32 c++ 应用程序发送 Toast 通知,但即使我选中“允许服务与 UI 交互”,我也无法通过 Windows 服务发送通知。 What do you think about the software Architecture??您如何看待软件架构? Do you think i should reconsider the software Architecture or there is any other way to send Toast notification through Windows Service?!你认为我应该重新考虑软件架构还是有任何其他方式通过 Windows 服务发送 Toast 通知?!

"Allow Service to Interact with UI" only has an effect until XP. “允许服务与 UI 交互”仅在 XP 之前有效。 Up to then, the first user logged in runs in Session 0, the same Session that services run in. But from Vista onwards, Session 0 is now isolated, users run in Session 1 and higher only, so services can no longer interact with users. Up to then, the first user logged in runs in Session 0, the same Session that services run in. But from Vista onwards, Session 0 is now isolated, users run in Session 1 and higher only, so services can no longer interact with users .

When you want your service to display a toast, have the service use CreateProcessAsUser() to spawn a separate process in an available user Session (plenty of examples floating around demonstrating how to do that), and then that process can display the toast as needed.当您希望您的服务显示 toast 时,让服务使用CreateProcessAsUser()在可用用户 Session 中生成一个单独的进程(大量示例漂浮在展示如何做到这一点),然后该进程可以根据需要显示 toast .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM