1

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.

Ashley Williams
  • 317
  • 4
  • 13
  • The UAC consent prompt is displayed on the secure desktop, knowing it is active is forbidden knowledge. Focus on the general failure mode, this is also going to happen when the screen-saver kicks in or the user locks the workstation (Win+L) for example. Handling device-lost situations is required, using the SystemEvents.SessionSwitch event is what you are asking for but it is merely a band-aid. – Hans Passant Jun 26 '17 at 07:50

2 Answers2

1

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.

SixZiv
  • 11
  • 1
0

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.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431