2

In a Windows desktop application written in C# and running on Windows 8 how can I detect if Windows 8 is in desktop mode (i.e. showing the Desktop rather than the modern UI)?

  • Good question, but I'm curious - why do you want to know? – Mark Ransom Dec 21 '12 at 20:16
  • I am showing a window in desktop mode informing the user that a USB device firmware update will begin in 5 minutes. If the desktop is not visible the user might not see this warning and the firmware update will start automatically. I know we could bring up a toast notification on the modern UI screen, but a toast will only appear for a few seconds so the user may not notice the toast notification. A better solution is not to start the 5 minutes countdown if the desktop is not visible. – Bo Christian Skjøtt Dec 21 '12 at 22:14

1 Answers1

4

Although it's in C++, the Start Screen Visibility Sample should be a good starting point for you. It uses COM objects to get the state of all monitors on the system that are either displaying Windows Store Apps or the Start Screen, and illustrates how to receive notifications when the state of a monitor changes or when the visibility of the Start screen changes.

SWalters
  • 3,615
  • 5
  • 30
  • 37
  • Thank you. That works. This link explains how to do it from C# using COM interop: http://stackoverflow.com/questions/12009999/imetromodeislaunchervisible-in-c-sharp-via-pinvoke – Bo Christian Skjøtt Feb 17 '13 at 16:47