Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

NtQueryWnfStateData (ntdll)
 
.
Summary
Returns the state of the Focus Assist feature in Windows 10 Build >= 17083

C# Signature:

[DllImport("ntdll.dll", SetLastError=true)]
private static extern uint NtQueryWnfStateData(IntPtr pStateName, IntPtr pTypeId, IntPtr pExplicitScope, out uint nChangeStamp, out IntPtr pBuffer, ref uint nBufferSize);

VB Signature:

Declare Function NtQueryWnfStateData Lib "ntdll.dll" (TODO) As TODO

User-Defined Types:

[StructLayout(LayoutKind.Sequential)]

public struct WNF_TYPE_ID

{

    public Guid TypeId;

}

[StructLayout(LayoutKind.Sequential)]

public struct WNF_STATE_NAME

{

    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
    public uint[] Data;

    public WNF_STATE_NAME(uint Data1, uint Data2) : this()
    {
    uint[] newData = new uint[2];
    newData[0] = Data1;
    newData[1] = Data2;
    Data = newData;
    }

}

public enum FocusAssistResult

{

    NOT_SUPPORTED = -2,
    FAILED = -1,
    OFF = 0,
    PRIORITY_ONLY = 1,
    ALARMS_ONLY = 2

};

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

This function replaces Quiet Hours in Windows 10 build >= 17083.

Tips & Tricks:

Please add some!

Sample Code:

private FocusAssistResult GetUserNotificationState()

{

    //  Focus Assist:   Windows 10 build >= 17083
    WNF_STATE_NAME WNF_SHEL_QUIETHOURS_ACTIVE_PROFILE_CHANGED = new WNF_STATE_NAME(0xA3BF1C75, 0xD83063E);
    uint nBufferSize = (uint)Marshal.SizeOf(typeof(IntPtr));
    IntPtr pStateName = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WNF_STATE_NAME)));
    Marshal.StructureToPtr(WNF_SHEL_QUIETHOURS_ACTIVE_PROFILE_CHANGED, pStateName, false);
    bool success = NtQueryWnfStateData(pStateName, IntPtr.Zero, IntPtr.Zero, out uint nChangeStamp, out IntPtr pBuffer, ref nBufferSize) == 0;
    Marshal.FreeHGlobal(pStateName);
    if (success)
    {
    return (FocusAssistResult)pBuffer;
    }

    return FocusAssistResult.FAILED;

}

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions