namespace Vanara.PInvoke; public static partial class Shell32 { /// Specifies whether a display is showing desktop windows instead of Windows Store apps. /// The MONITOR_APP_VISIBILITY enum is used by the GetAppVisibilityOnMonitor method. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-monitor_app_visibility typedef enum // MONITOR_APP_VISIBILITY { MAV_UNKNOWN, MAV_NO_APP_VISIBLE, MAV_APP_VISIBLE } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.MONITOR_APP_VISIBILITY")] public enum MONITOR_APP_VISIBILITY { /// The display state is not known. MAV_UNKNOWN, /// The display is showing desktop windows. MAV_NO_APP_VISIBLE, /// The display is not showing desktop windows. MAV_APP_VISIBLE, } /// Provides functionality to determine whether the display is showing Windows Store apps. /// /// /// Use the IAppVisibility interface to determine when a display is showing Windows Store apps. This is useful for /// accessibility tools and other applications. /// /// Use the IsLauncherVisible method to determine when the Start screen is visible. /// Don't implement the IAppVisibility interface. Instead, call the CoCreateInstance function with CLSID_AppVisibility. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iappvisibility [ComImport, Guid("2246EA2D-CAEA-4444-A3C4-6DE827E44313"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(AppVisibility))] public interface IAppVisibility { /// Queries the current mode of the specified monitor. /// The monitor to query. /// The current mode of hMonitor. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibility-getappvisibilityonmonitor // HRESULT GetAppVisibilityOnMonitor( HMONITOR hMonitor, MONITOR_APP_VISIBILITY *pMode ); MONITOR_APP_VISIBILITY GetAppVisibilityOnMonitor(HMONITOR hMonitor); /// Gets a value that indicates whether the Start screen is displayed. /// TRUE if the Start screen is displayed; otherwise, FALSE. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibility-islaunchervisible HRESULT // IsLauncherVisible( BOOL *pfVisible ); [return: MarshalAs(UnmanagedType.Bool)] bool IsLauncherVisible(); /// Registers an advise sink object to receive notification of changes to the display. /// The client's advise sink that receives outgoing calls from the connection point. /// /// A token that uniquely identifies this connection. Use this token to delete the connection by passing it to the Unadvise method. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibility-advise HRESULT Advise( // IAppVisibilityEvents *pCallback, DWORD *pdwCookie ); void Advise(IAppVisibilityEvents pCallback, out uint pdwCookie); /// Cancels a connection that was previously established by using Advise. /// /// A token that uniquely identifies the connection to cancel, which is provided by a previous call to to the Advise method. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibility-unadvise HRESULT Unadvise( // DWORD dwCookie ); void Unadvise(uint dwCookie); } /// Enables applications to receive notifications of state changes in a display and of changes in Start screen visibility. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iappvisibilityevents [ComImport, Guid("6584CE6B-7D82-49C2-89C9-C6BC02BA8C38"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAppVisibilityEvents { /// Notifies a client that the mode of a display has changed. /// The display that has a changing mode. /// /// The previous mode of hMonitor, which may be MAV_UNKNOWN if the client was unaware of the display previously. /// /// The current mode of hMonitor, which will not be MAV_UNKNOWN. /// The return value is ignored. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibilityevents-appvisibilityonmonitorchanged // HRESULT AppVisibilityOnMonitorChanged( HMONITOR hMonitor, MONITOR_APP_VISIBILITY previousMode, MONITOR_APP_VISIBILITY // currentMode ); [PreserveSig] HRESULT AppVisibilityOnMonitorChanged(HMONITOR hMonitor, MONITOR_APP_VISIBILITY previousMode, MONITOR_APP_VISIBILITY currentMode); /// Notifies a client that visibility of the Start screen has changed. /// TRUE if the Start screen is displayed; otherwise, FALSE. /// The return value is ignored. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iappvisibilityevents-launchervisibilitychange // HRESULT LauncherVisibilityChange( BOOL currentVisibleState ); [PreserveSig] HRESULT LauncherVisibilityChange([MarshalAs(UnmanagedType.Bool)] bool currentVisibleState); } /// CoClass for AppVisibility [PInvokeData("shobjidl.h")] [ComImport, Guid("7E5FE3D9-985F-4908-91F9-EE19F9FD1514"), ClassInterface(ClassInterfaceType.None)] public class AppVisibility { } }