private static void RegiterShNotify(Window window) { var handle = (new WindowInteropHelper(window)).Handle; var hwndSource = HwndSource.FromHwnd(handle); hwndSource.AddHook(WndProc); // WM_SHNOTIFY をハンドルするためのおまじない var notifyEntry = new Shell32.SHChangeNotifyEntry() { pIdl = IntPtr.Zero, Recursively = true }; var notifyId = Shell32.SHChangeNotifyRegister(handle, Shell32.Constant.SHCNF_TYPE | Shell32.Constant.SHCNF_IDLIST, Shell32.Constant.SHCNE_MEDIAINSERTED | Shell32.Constant.SHCNE_MEDIAREMOVED, (uint)Shell32.Constant.WM_SHNOTIFY, 1, ref notifyEntry); }
private static void RegiterShNotify(Window window) { var handle = (new WindowInteropHelper(window)).Handle; var hwndSource = HwndSource.FromHwnd(handle); hwndSource.AddHook(WndProc); // WM_SHNOTIFY をハンドルするためのおまじない var notifyEntry = new Shell32.SHChangeNotifyEntry() { pIdl = IntPtr.Zero, Recursively = true }; var notifyId = Shell32.SHChangeNotifyRegister(handle, Shell32.Constant.SHCNF_TYPE | Shell32.Constant.SHCNF_IDLIST, Shell32.Constant.SHCNE_MEDIAINSERTED | Shell32.Constant.SHCNE_MEDIAREMOVED, (uint)Shell32.Constant.WM_SHNOTIFY, 1, ref notifyEntry); }