public static extern uint SHChangeNotifyRegister(
     IntPtr windowHandle,
     ShellChangeNotifyEventSource sources,
     ShellObjectChangeTypes events,
     uint message,
     int entries,
     ref SHChangeNotifyEntry changeNotifyEntry);
Example #2
0
 private static extern uint SHChangeNotifyRegister(
     IntPtr hWnd,
     SHCNF fSources,
     SHCNE fEvents,
     int wMsg,
     int cEntries,
     ref SHChangeNotifyEntry pFsne);
        /// <summary>
        ///     Start shell watcher.
        /// </summary>
        public void Start()
        {
            if (this.Running)
            {
                return;
            }

            var entry = new SHChangeNotifyEntry
            {
                fRecursive = this.recursive,
                pidl       = this.shellObject.ShellItem.PIDL
            };

            const Int32 flags = SHCNRF.SHCNRF_ShellLevel |
                                SHCNRF.SHCNRF_InterruptLevel |
                                SHCNRF.SHCNRF_NewDelivery;

            this.registrationId = ShellWatcherNativeMethods.SHChangeNotifyRegister(
                this.ListenerWindow.Handle,
                flags,
                this.eventManager.RegisteredTypes,
                this.Message,
                1,
                ref entry);
            if (this.registrationId == 0)
            {
                throw new Win32Exception(ErrorMessages.ShellWatcherRegisterFailed);
            }

            this.Running = true;
        }
Example #4
0
            public NotificationWindow(ShellNotificationListener parent)
            {
                SHChangeNotifyEntry notify = new SHChangeNotifyEntry();

                notify.pidl       = ShellItem.Desktop.Pidl;
                notify.fRecursive = true;
                m_NotifyId        = Shell32.SHChangeNotifyRegister(this.Handle,
                                                                   SHCNRF.InterruptLevel | SHCNRF.ShellLevel,
                                                                   SHCNE.ALLEVENTS, WM_SHNOTIFY, 1, ref notify);
                m_Parent = parent;
            }
Example #5
0
            public NotificationWindow(ShellNotificationListener parent)
            {
                var notify = new SHChangeNotifyEntry
                {
                    pidl       = ShellItem.Desktop.Pidl,
                    fRecursive = true
                };

                _mNotifyId = Shell32.SHChangeNotifyRegister(Handle,
                                                            SHCNRF.InterruptLevel | SHCNRF.ShellLevel,
                                                            SHCNE.ALLEVENTS, WmShnotify, 1, ref notify);
                _mParent = parent;
            }
Example #6
0
     public Form1()
     {
         InitializeComponent();
 
         SHChangeNotifyEntry changeEntry = new SHChangeNotifyEntry();
 
         changeEntry.dwEventMask = (uint)SHCNE.SHCNE_CREATE;
         changeEntry.Recursive = false;
         changeEntry.pszWatchDir = "\\My Documents\\";
 
         try
         {
             bool result = SHChangeNotifyRegister(this.Handle, ref changeEntry);
         }
         catch (Exception ee)
         {
 
         }
     }
Example #7
0
        /// <summary>
        /// シェルのチェンジイベント受付を登録する
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="folderID"></param>
        /// <param name="recursively"></param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
        {
            if (notifyid != 0)
            {
                return(0);
            }
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();

            changeentry.pIdl        = GetPidlFromFolderID(hWnd, folderID);
            changeentry.Recursively = recursively;
            notifyid = SHChangeNotifyRegister(
                hWnd,
                SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
                SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                (int)WM.WM_SHNOTIFY,
                1,
                ref changeentry);
            return(notifyid);
        }
Example #8
0
        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// !!!!! Add this code to your registered form : !!!!!
        /// protected override void WndProc(ref Message m)
        /// {
        ///		switch(m.Msg)
        ///		{
        ///			case (int) ShellNotifications.WM_SHNOTIFY:
        ///			if(Notifications.NotificationReceipt(m.WParam, m.LParam))
        ///				NewOperation((NotifyInfos) Notifications.NotificationsReceived[Notifications.NotificationsReceived.Count-1]);
        ///			break;
        ///		}
        ///		base.WndProc(ref m);
        /// }
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="FolderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
        /// <param name="Recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL FolderID, bool Recursively)
        {
            if (notifyid != 0)
            {
                return(0);
            }
            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();
            IntPtr ppidl = IntPtr.Zero;

            ppidl                   = GetPidlFromFolderID(hWnd, FolderID);
            changeentry.pIdl        = ppidl;
            changeentry.Recursively = Recursively;
            notifyid                = SHChangeNotifyRegister(
                hWnd,
                SHCNRF.InterruptLevel | SHCNRF.ShellLevel,
                SHCNE.SHCNE_ALLEVENTS,
                WM_SHNOTIFY,
                1,
                ref changeentry);
            return(notifyid);
        }
        /// <summary>
        /// Register a form handle
        /// This form will receive a WM_SHNOTIFY when a notification occures
        ///
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="folderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
        /// <param name="recursively">Look recursively at modifications</param>
        /// <returns></returns>
        public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
        {
            if (_notifyid != 0)
            {
                return(0);
            }

            SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();

            changeentry.pIdl        = GetPidlFromFolderID(hWnd, folderID);
            changeentry.Recursively = recursively;

            _notifyid = SHChangeNotifyRegister(
                hWnd,
                SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
                //SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
                SHCNE.SHCNE_MEDIAINSERTED | SHCNE.SHCNE_MEDIAREMOVED,
                WmShnotify,
                1,
                ref changeentry);
            return(_notifyid);
        }
Example #10
0
            public DummyForm()
            {
                var notifyEntry = new SHChangeNotifyEntry()
                {
                    pIdl = IntPtr.Zero, Recursively = true
                };

                notifyId = SHChangeNotifyRegister(Handle,
                                                  SHCNF.TYPE | SHCNF.IDLIST, SHCNE.MEDIAINSERTED | SHCNE.MEDIAREMOVED,
                                                  (uint)WM.SHNOTIFY, 1, ref notifyEntry);

                drivemask = 0;
                var dd = DriveInfo.GetDrives();

                foreach (var d in dd)
                {
                    uint mask = 1u << (d.Name[0] - 'A');
                    if (d.IsReady)
                    {
                        drivemask |= mask;
                    }
                }
            }
    /// <summary>
    /// Register a form handle
    /// This form will receive a WM_SHNOTIFY when a notification occures
    /// 
    /// </summary>
    /// <param name="hWnd"></param>
    /// <param name="folderID">Root folder of the 'spy' (CSIDL_DESKTOP vor example)</param>
    /// <param name="recursively">Look recursively at modifications</param>
    /// <returns></returns>
    public ulong RegisterChangeNotify(IntPtr hWnd, CSIDL folderID, bool recursively)
    {
      if (_notifyid != 0)
      {
        return (0);
      }
      
      SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();
      changeentry.pIdl = GetPidlFromFolderID(hWnd, folderID);
      changeentry.Recursively = recursively;

      _notifyid = SHChangeNotifyRegister(
        hWnd,
        SHCNF.SHCNF_TYPE | SHCNF.SHCNF_IDLIST,
        //SHCNE.SHCNE_ALLEVENTS | SHCNE.SHCNE_INTERRUPT,
        SHCNE.SHCNE_MEDIAINSERTED | SHCNE.SHCNE_MEDIAREMOVED,
        WmShnotify,
        1,
        ref changeentry);
      return (_notifyid);
    }
 public static extern UInt32 SHChangeNotifyRegister(IntPtr hWnd, int fSources, SHCNE fEvents, uint wMsg, int cEntries, ref SHChangeNotifyEntry pFsne);
Example #13
0
 internal static extern uint SHChangeNotifyRegister(
     IntPtr windowHandle,
     ShellChangeNotifyEventSource sources,
     ShellObjectChangeTypes events,
     uint message,
     int entries,
     ref SHChangeNotifyEntry changeNotifyEntry);
Example #14
0
 public static extern uint SHChangeNotifyRegister(IntPtr hWnd, int fSources, int fEvents, uint wMsg, int cEntries, ref SHChangeNotifyEntry pFsne);
Example #15
0
 private static extern bool SHChangeNotifyRegister(IntPtr hwnd, ref SHChangeNotifyEntry test);
Example #16
0
 internal static extern UInt32 SHChangeNotifyRegister(IntPtr oHWnd, SHCNRF oSources, SHCNE oEvents, UInt32 oMsg, Int32 oEntries, ref SHChangeNotifyEntry oShCne);
Example #17
-6
 private static extern uint SHChangeNotifyRegister(
   IntPtr hWnd,
   SHCNF fSources,
   SHCNE fEvents,
   uint wMsg,
   int cEntries,
   ref SHChangeNotifyEntry pFsne);