private static extern uint SHChangeNotifyRegister( IntPtr hWnd, SHCNF fSources, SHCNE fEvents, int wMsg, int cEntries, ref SHChangeNotifyEntry pFsne);
private void OnChangeNotify(SHCNE lEvent, IShellItem2 psi1, IShellItem2 psi2) { string pszLeft = null, pszRight = null; if (psi1 != null) { pszLeft = GetIDListName(psi1); } if (psi2 != null) { pszRight = GetIDListName(psi2); } if (lEvent == SHCNE.SHCNE_RENAMEITEM || lEvent == SHCNE.SHCNE_RENAMEFOLDER) { LogMessage(GROUPID.NAMES, lEvent.ToString(), $"{pszLeft ?? string.Empty} ==> {pszRight ?? string.Empty}"); } else { LogMessage(GROUPID.NAMES, lEvent.ToString(), $"{pszLeft ?? string.Empty} , {pszRight ?? string.Empty}"); } AutoAdjustListView(); }
private static extern uint SHChangeNotifyRegister( IntPtr hWnd, SHCNRF fSources, SHCNE fEvents, uint wMsg, int cEntries, [MarshalAs(UnmanagedType.LPArray)] SHChangeNotifyEntry[] pFsne);
/// <summary> /// ドライブのマウント系のメッセージか判断する /// </summary> /// <param name="lParam"></param> /// <returns></returns> public bool IsDriveMount(IntPtr lParam) { SHCNE notification = (SHCNE)(int)lParam; switch (notification) { case SHCNE.SHCNE_DRIVEADD: return(true); case SHCNE.SHCNE_MEDIAINSERTED: return(true); default: return(false); } }
public HRESULT StartWatching(IShellItem psi, HWND hwnd, uint uMsg, SHCNE lEvents, bool fRecursive) { StopWatching(); var hr = SHGetIDListFromObject(psi, out var pidlWatch); using (pidlWatch) if (hr.Succeeded) { SHChangeNotifyEntry[] entries = { new SHChangeNotifyEntry { pidl = (IntPtr)pidlWatch, fRecursive = fRecursive } }; _ulRegister = SHChangeNotifyRegister(hwnd, SHCNRF.SHCNRF_ShellLevel | SHCNRF.SHCNRF_InterruptLevel | SHCNRF.SHCNRF_NewDelivery, lEvents, uMsg, entries.Length, entries); hr = _ulRegister != 0 ? HRESULT.S_OK : HRESULT.E_FAIL; } return(hr); }
public static extern uint SHChangeNotifyRegister(IntPtr hwnd, SHCNRF fSources, SHCNE fEvents, WM wMsg, int cEntries, [MarshalAs(UnmanagedType.LPArray)] SHChangeNotifyEntry[] pfsne);
public static extern UInt32 SHChangeNotifyRegister(IntPtr hWnd, int fSources, SHCNE fEvents, uint wMsg, int cEntries, ref SHChangeNotifyEntry pFsne);
// derived class implements this event protected void OnChangeNotify(SHCNE lEvent, IShellItem2 psi1, IShellItem2 psi2) => ChangeNotify?.Invoke(lEvent, psi1, psi2);
internal static extern UInt32 SHChangeNotifyRegister(IntPtr oHWnd, SHCNRF oSources, SHCNE oEvents, UInt32 oMsg, Int32 oEntries, ref SHChangeNotifyEntry oShCne);
public static extern int SHChangeNotify(SHCNE eventId, SHCNF flags, IntPtr item1, IntPtr item2);
private static extern uint SHChangeNotifyRegister( IntPtr hWnd, SHCNF fSources, SHCNE fEvents, uint wMsg, int cEntries, ref SHChangeNotifyEntry pFsne);