Structure that contain informations about a notification
Beispiel #1
0
        /// <summary>
        /// Message received from the WndProc of a registered form
        /// </summary>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns>True if this is a new notification</returns>
        public bool NotificationReceipt(IntPtr wParam, IntPtr lParam)
        {
            IntPtr ptr;
            uint   eventID;
            var    lockPtr = Shell32.SHChangeNotification_Lock(wParam, (int)lParam, out ptr, out eventID);

            try
            {
                SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure(
                    ptr,
                    typeof(SHNOTIFYSTRUCT));
                NotifyInfos info = new NotifyInfos((SHCNE)(int)eventID);
                //System.Windows.Forms.MessageBox.Show(info.Notification.ToString());

                //Not supported notifications
                //if (info.Notification == SHCNE.SHCNE_FREESPACE ||
                //    info.Notification == SHCNE.SHCNE_UPDATEIMAGE)
                //    return (false);

                info.Item1 = shNotify.dwItem1;
                info.Item2 = shNotify.dwItem2;

                // Was this notification in the received notifications ?
                if (NotificationsReceived.Contains(info))
                {
                    return(false);
                }
                NotificationsReceived.Add(info);
            }
            finally
            {
                if (lockPtr != IntPtr.Zero)
                {
                    Shell32.SHChangeNotification_Unlock(lockPtr);
                }
            }
            return(true);
            //DisplayName1 = GetDisplayNameFromPidl(shNotify.dwItem1);
            //DisplayName2 = GetDisplayNameFromPidl(shNotify.dwItem2);
        }
        /// <summary>
        /// Message received from the WndProc of a registered form
        /// </summary>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns>True if this is a new notification</returns>
        public bool NotificationReceipt(IntPtr wParam, IntPtr lParam)
        {
            IntPtr ptr;
            uint eventID;
            var lockPtr = Shell32.SHChangeNotification_Lock(wParam, (int)lParam, out ptr, out eventID);
            try
            {

                SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure(
                    ptr,
                    typeof(SHNOTIFYSTRUCT));
                NotifyInfos info = new NotifyInfos((SHCNE)(int)eventID);
                //System.Windows.Forms.MessageBox.Show(info.Notification.ToString());

                //Not supported notifications
                //if (info.Notification == SHCNE.SHCNE_FREESPACE ||
                //    info.Notification == SHCNE.SHCNE_UPDATEIMAGE)
                //    return (false);

                info.Item1 = shNotify.dwItem1;
                info.Item2 = shNotify.dwItem2;

                // Was this notification in the received notifications ?
                if (NotificationsReceived.Contains(info)) return (false);
                NotificationsReceived.Add(info);
            }
            finally
            {
                if (lockPtr != IntPtr.Zero)
                    Shell32.SHChangeNotification_Unlock(lockPtr);
            }
            return (true);
            //DisplayName1 = GetDisplayNameFromPidl(shNotify.dwItem1);
            //DisplayName2 = GetDisplayNameFromPidl(shNotify.dwItem2);
        }