简体   繁体   English

UAC风格的提升提示

[英]UAC-style elevated prompt

I'm interested in launching a window in a temporary session, like how UAC prompts appear. 我对在临时会话中启动窗口感兴趣,例如UAC提示的显示方式。 There's been some interest in this concept from a few people, so I figured I'd ask here. 几个人对此概念有些兴趣,所以我想在这里问一下。 Essentially what we're going for is an elevated window like the UAC "are you sure you want to <...>" prompts, but with an arbitrary window. 本质上,我们要使用的是高架窗口,例如UAC“您确定要<...>”提示,但是具有任意窗口。 The end goal is to prevent window event hooks and all sorts of other issues that might occur during password entry. 最终目标是防止在输入密码的过程中发生窗口事件挂钩和其他各种问题。

I've had a quick look at the UAC APIs and a few other places, but there's nothing particularly useful out there. 我快速浏览了UAC API和其他一些地方,但是那里没有什么特别有用的。 Obviously the UAC prompts get elevated to their own desktop session somehow , so there must be a way to create windows in such a way. 显然,UAC提示会以某种方式提升到其自己的桌面会话,因此必须有一种以这种方式创建窗口的方法。

You can create a desktop using CreateDesktop . 您可以使用CreateDesktop创建桌面。 You can use SwitchDesktop to switch to the new desktop. 您可以使用SwitchDesktop切换到新桌面。 Then you can call SetThreadDesktop on your main thread and draw your window. 然后,您可以在主线程上调用SetThreadDesktop并绘制窗口。 To get back get the handle of the default desktop by calling OpenDesktop with "Default" as lpszDesktop and use SwitchDesktop with this handle. 要获取默认桌面的句柄,请使用“ Default”作为lpszDesktop调用OpenDesktop并在此句柄中使用SwitchDesktop。 You can also run Processes on a certain desktop. 您也可以在特定桌面上运行进程。 In order to do this you have to set lpDesktop member of the STARTUPINFO structure to the name of the desktop the process should be run on. 为此,您必须将STARTUPINFO结构的lpDesktop成员设置为应在其上运行该进程的桌面的名称。 Close the handles to the desktops after using them ( CloseDesktop ). 使用完桌面后,关闭它们的手柄( CloseDesktop )。

You can show your own window on an own desktop in this way. 您可以通过这种方式在自己的桌面上显示自己的窗口。

The secure desktop used by UAC and by the Logon UI is called "Winlogon". UAC和登录UI使用的安全桌面称为“ Winlogon”。 In order to access it you need system rights. 为了访问它,您需要系统权限。 Luke provided an example in one of his answers . 卢克(Luke)在他的回答中举了一个例子。

Brian R. Bondy wrote a blog entry on desktops and window stations which is worth reading. Brian R. Bondy 在台式机和窗口站上写了一个博客条目,值得一读。

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

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