/// <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) { SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure( wParam, typeof(SHNOTIFYSTRUCT)); NotifyInfos info = new NotifyInfos((SHCNE)(int)lParam); //Not supported notifications if (info.Notification == SHCNE.SHCNE_FREESPACE || info.Notification == SHCNE.SHCNE_UPDATEIMAGE) { return(false); } info.Item1 = GetPathFromPidl(shNotify.dwItem1); info.Item2 = GetPathFromPidl(shNotify.dwItem2); // Was this notification in the received notifications ? //if (NotificationsReceived.Contains(info)) // return (false); NotificationsReceived.Add(info); 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> /// <param name="info"></param> public bool NotificationReceipt(IntPtr wParam, IntPtr lParam, ref NotifyInfos info) { SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure(wParam, typeof(SHNOTIFYSTRUCT)); if (info.Notification == SHCNE.SHCNE_FREESPACE || info.Notification == SHCNE.SHCNE_UPDATEIMAGE) { return(false); } info.Item1 = GetPathFromPidl(shNotify.dwItem1); info.Item2 = GetPathFromPidl(shNotify.dwItem2); return(true); }
/// <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) { SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure( wParam, typeof(SHNOTIFYSTRUCT)); NotifyInfos info = new NotifyInfos((SHCNE)(int)lParam); //Not supported notifications if (info.Notification == SHCNE.SHCNE_FREESPACE || info.Notification == SHCNE.SHCNE_UPDATEIMAGE) { return(false); } //if (!(info.Notification == SHCNE.SHCNE_CREATE || info.Notification == SHCNE.SHCNE_DELETE || info.Notification == SHCNE.SHCNE_UPDATEDIR)) // return false; info.Item1 = GetPathFromPidl(shNotify.dwItem1); info.Item2 = GetPathFromPidl(shNotify.dwItem2); if (info.Item1.ToUpperInvariant().Contains("$RECYCLE.BIN") || info.Item2.ToUpperInvariant().Contains("$RECYCLE.BIN")) { // Was this notification in the received notifications ? if (NotificationsReceived.Contains(info)) { return(false); } NotificationsReceived.Add(info); return(true); } else { return(false); } //if (info.Notification != SHCNE.SHCNE_DELETE) // return false; //DisplayName1 = GetDisplayNameFromPidl(shNotify.dwItem1); //DisplayName2 = GetDisplayNameFromPidl(shNotify.dwItem2); }
/// <summary> /// マウントされたドライブパスを返却する /// </summary> /// <param name="wParam"></param> /// <returns></returns> public string GetDrivePath(IntPtr wParam) { SHNOTIFYSTRUCT shNotify = (SHNOTIFYSTRUCT)Marshal.PtrToStructure(wParam, typeof(SHNOTIFYSTRUCT)); return(GetPathFromPidl(shNotify.dwItem1)); }
protected override void WndProc(ref Message m) { if (m.Msg == WM_SHNOTIFY) { SHNOTIFYSTRUCT notify = (SHNOTIFYSTRUCT) Marshal.PtrToStructure(m.WParam, typeof(SHNOTIFYSTRUCT)); switch ((SHCNE)m.LParam) { case SHCNE.CREATE: if (m_Parent.ItemCreated != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.ItemCreated(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.DELETE: if (m_Parent.ItemDeleted != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.ItemDeleted(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.DRIVEADD: if (m_Parent.DriveAdded != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.DriveAdded(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.DRIVEREMOVED: if (m_Parent.DriveRemoved != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.DriveRemoved(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.MKDIR: if (m_Parent.FolderCreated != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.FolderCreated(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.RMDIR: if (m_Parent.FolderDeleted != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.FolderDeleted(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.UPDATEDIR: if (m_Parent.FolderUpdated != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.FolderUpdated(m_Parent, new ShellItemEventArgs(item)); } break; case SHCNE.UPDATEITEM: if (m_Parent.ItemUpdated != null) { ShellItem item = new ShellItem(notify.dwItem1); // FAB! 14/9/17 itérations énormes en cas de dragdrop if (!item.IsFileSystem) { m_Parent.ItemUpdated(m_Parent, new ShellItemEventArgs(item)); } } break; case SHCNE.RENAMEFOLDER: if (m_Parent.FolderRenamed != null) { ShellItem item1 = new ShellItem(notify.dwItem1); ShellItem item2 = new ShellItem(notify.dwItem2); m_Parent.FolderRenamed(m_Parent, new ShellItemChangeEventArgs(item1, item2)); } break; case SHCNE.RENAMEITEM: if (m_Parent.ItemRenamed != null) { ShellItem item1 = new ShellItem(notify.dwItem1); ShellItem item2 = new ShellItem(notify.dwItem2); m_Parent.ItemRenamed(m_Parent, new ShellItemChangeEventArgs(item1, item2)); } break; case SHCNE.NETSHARE: case SHCNE.NETUNSHARE: if (m_Parent.SharingChanged != null) { ShellItem item = new ShellItem(notify.dwItem1); m_Parent.SharingChanged(m_Parent, new ShellItemEventArgs(item)); } break; } } else { base.WndProc(ref m); } }