using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// /// /// Exposes methods that set notification information and then display that notification to the user in a balloon that appears in /// conjunction with the notification area of the taskbar. /// /// /// Note IUserNotification2 differs from IUserNotification only in its Show method, which adds an additional parameter /// for a callback interface to communicate with the notification. Otherwise the two interfaces are identical in form and function. /// CLSID_UserNotification implements both versions of Show as an overload. /// /// /// /// When to Implement /// An implementation of this interface is provided in Windows as CLSID_UserNotification. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iusernotification [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IUserNotification")] [ComImport, Guid("ba9711ba-5893-4787-a7e1-41277151550b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IUserNotification { /// Sets the information to be displayed in a balloon notification. /// /// Type: LPCWSTR /// A pointer to a Unicode string that specifies the title of the notification. /// /// /// Type: LPCWSTR /// A pointer to a Unicode string that specifies the text to be displayed in the body of the balloon. /// /// /// Type: DWORD /// One or more of the following values that indicate an icon to display in the notification balloon. /// NIIF_NONE (0x00000000) /// 0x00000000. Do not display an icon. /// NIIF_INFO (0x00000001) /// 0x00000001. Display an information icon. /// NIIF_WARNING (0x00000002) /// 0x00000002. Display a warning icon. /// NIIF_ERROR (0x00000003) /// 0x00000003. Display an error icon. /// NIIF_USER (0x00000004) /// 0x00000004. Windows XP SP2 and later. Use the icon identified in hIcon in the notification balloon. /// NIIF_NOSOUND (0x00000010) /// /// 0x00000010. Windows XP and later. Do not play the associated sound. This value applies only to balloon notifications /// and not to standard user notifications. /// /// NIIF_LARGE_ICON (0x00000010) /// /// 0x00000010. Windows Vista and later. The large version of the icon should be used as the icon in the notification /// balloon. This corresponds to the icon with dimensions SM_CXICON x SM_CYICON. If this flag is not set, the icon with /// dimensions XM_CXSMICON x SM_CYSMICON is used. /// /// /// /// This flag can be used with all stock icons. /// /// /// /// Applications that use older customized icons (NIIF_USER with hIcon) must provide a new SM_CXICON x SM_CYICON version /// in the tray icon specified in the hIcon member of the NOTIFYICONDATA structure. These icons are scaled down when they /// are displayed in the notification area. /// /// /// /// /// New customized icons (NIIF_USER with hBalloonIcon) must supply an SM_CXICON x SM_CYICON version in the supplied icon /// ( hBalloonIcon). /// /// /// /// NIIF_RESPECT_QUIET_TIME (0x00000080) /// /// 0x00000080. Windows 7 and later. Do not display the notification balloon if the current user is in "quiet time", /// which is the first hour after a new user logs into his or her account for the first time. During this time, most /// notifications should not be sent or shown. This lets a user become accustomed to a new computer system without those /// distractions. Quiet time also occurs for each user after an operating system upgrade or clean installation. A notification /// sent with this flag during quiet time is not queued; it is simply dismissed unshown. The application can resend the /// notification later if it is still valid at that time. /// /// /// Because an application cannot predict when it might encounter quiet time, we recommended that this flag always be set on all /// appropriate notifications by any application that means to honor quiet time. /// /// If the current user is not in quiet time, this flag has no effect. /// NIIF_ICON_MASK (0x0000000F) /// 0x0000000F. Windows XP (Shell32.dll version 6.0 ) and later. Reserved. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iusernotification-setballooninfo HRESULT // SetBalloonInfo( LPCWSTR pszTitle, LPCWSTR pszText, DWORD dwInfoFlags ); void SetBalloonInfo([MarshalAs(UnmanagedType.LPWStr)] string pszTitle, [MarshalAs(UnmanagedType.LPWStr)] string pszText, NIIF dwInfoFlags); /// Specifies the conditions for trying to display user information when the first attempt fails. /// /// Type: DWORD /// The amount of time, in milliseconds, to display the user information. /// /// /// Type: DWORD /// The interval of time, in milliseconds, between attempts to display the user information. /// /// /// Type: UINT /// The number of times the system should try to display the user information. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iusernotification-setballoonretry HRESULT // SetBalloonRetry( DWORD dwShowTime, DWORD dwInterval, UINT cRetryCount ); void SetBalloonRetry(uint dwShowTime, uint dwInterval, uint cRetryCount); /// Sets the notification area icon associated with specific user information. /// /// Type: HICON /// A handle to the icon. /// /// /// Type: LPCWSTR /// /// A pointer to a string that contains the tooltip text to display for the specified icon. This value can be NULL, /// although it is not recommended. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iusernotification-seticoninfo HRESULT // SetIconInfo( HICON hIcon, LPCWSTR pszToolTip ); void SetIconInfo(HICON hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszToolTip); /// Displays the notification. /// /// Type: IQueryContinue* /// /// An IQueryContinue interface pointer, used to determine whether the notification display can continue or should stop (for /// example, if the user closes the notification). This value can be NULL. /// /// /// /// Type: DWORD /// The length of time, in milliseconds, to display user information. /// /// This method is equivalent to calling Show with pSink= NULL. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iusernotification-show HRESULT Show( // IQueryContinue *pqc, DWORD dwContinuePollInterval ); void Show(IQueryContinue pqc, uint dwContinuePollInterval); /// Plays a sound in conjunction with the notification. /// /// Type: LPCWSTR /// A pointer to a null-terminated Unicode string that specifies the alias of the sound file to play. /// /// /// /// The string pointed to by pszSoundNamepqc contains an alias for a system event found in the registry or the Win.ini file; for /// instance, "SystemExit". /// /// /// The specified sound is played asynchronously and the method returns immediately after beginning the sound. To stop an /// asynchronous waveform sound, call IUserNotification::PlaySound with pszSoundNamepqc set to NULL. /// /// /// The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the /// resource needed to play that sound is busy, the method immediately returns S_FALSE without playing the requested sound. /// /// If the specified sound cannot be found, IUserNotification::PlaySound uses the system default sound. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iusernotification-playsound HRESULT // PlaySound( LPCWSTR pszSoundName ); void PlaySound([MarshalAs(UnmanagedType.LPWStr)] string pszSoundName); } } }