SHQueryUserNotificationState indicates a QUERY_USER_NOTIFICATION_STATE of QUNS_QUIET_TIME or QUNS_RUNNING_D3D_FULL_SCREEN

Viewed 201

I have already asked a SO question here on proper usage of SHQueryUserNotificationState(). I assume that my implementation is correct but will link to it in case that is my problem:

How to implement SHQueryUserNotificationState in VB.net

My question is about the QUERY_USER_NOTIFICATION_STATE.

I get the state of QUNS_QUIET_TIME even though I have the focus assistant turned off, and for example I get notifications for emails.

Further, I otherwise only get QUNS_RUNNING_D3D_FULL_SCREEN under the following conditions:

  • Presenting in Powerpoint
  • presenting/sharing screen in MSTeams
  • F11 Full Screen in Firefox/Chrome
  • Watching YouTube in full screen in a browser

Is this to be expected on a Windows 10 OS? I would have thought that I would get QUNS_BUSY in some cases, at least.

1 Answers

I cannot reproduce this issue on win10 2004 in C++.

According to the shellapi.h in win10(and the version of win7 on github):

typedef enum
{
    QUNS_NOT_PRESENT               = 1,    // The user is not present.  Heuristic check for modes like: screen saver, locked machine, non-active FUS session
    QUNS_BUSY                      = 2,    // The user is busy.  Heuristic check for modes like: full-screen app
    QUNS_RUNNING_D3D_FULL_SCREEN   = 3,    // full-screen (exlusive-mode) D3D app
    QUNS_PRESENTATION_MODE         = 4,    // Windows presentation mode (laptop feature) is turned on
    QUNS_ACCEPTS_NOTIFICATIONS     = 5,    // notifications can be freely sent
#if (NTDDI_VERSION >= NTDDI_WIN7)
    QUNS_QUIET_TIME                = 6,    // We are in OOBE quiet period
#endif
#if (NTDDI_VERSION >= NTDDI_WIN8)
    QUNS_APP                       = 7,    // App-mode application
#endif
} QUERY_USER_NOTIFICATION_STATE;

The 1st member of enum starts from the value 1, and your definition starts from the value 0, so the values you get are all misplaced. You need to define like:

Public Enum QUERY_USER_NOTIFICATION_STATE
    QUNS_NOT_PRESENT = 1
    QUNS_BUSY
    QUNS_RUNNING_D3D_FULL_SCREEN
    QUNS_PRESENTATION_MODE
    QUNS_ACCEPTS_NOTIFICATIONS
    QUNS_QUIET_TIME
    QUNS_APP
End Enum
Related