How to check is UAC is currently blacking out the screen?

北战南征 提交于 2020-05-16 05:36:23

问题


I am trying to determine if User Account Control is currently blacking out the screen/asking for permission.

I have an application which uses SlimDX and when UAC takes over the screen it causes the DirectX device to be lost, I can recreate the device once the UAC window has been closed, if I try this before(even in a try{}catch{} and loop the application crashes)

I have looked over at pinvoke and msdn and I can't seem to find anything about this. Does anyone have an ideas?

As a note: I do not want to interact with these prompts in any way, I only want to check if they are open so I can delay the creation of my DirectX device.


回答1:


If a UAC prompt is currently on screen then C:\Windows\System32\consent.exe will be running. There are ways to be notified with a event when a program starts or stops, you can use them and have your program perform the action to recreate the DirectX device after the consent.exe program terminates.




回答2:


Sorry for making a late answer. But I think it may help. As far as I see, you are not looking for a way to see if UAC is running, but a way to check whether UAC is blocking the screen. I've confirmed that UAC is using SwitchDesktop to change to another desktop, so you can just use GetInputDesktop to get the 'active' desktop. Then use GetUserObjectInformation to check its name. The 'normal' desktop should be default, while UAC will be running on the WinLogon desktop. Wish it will help.



来源:https://stackoverflow.com/questions/44751919/how-to-check-is-uac-is-currently-blacking-out-the-screen

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