/// <summary> /// Actually performs unregistration. The ComUnregisterFunction decorated method will call this function /// internally with the flag appropriate for the operating system processor architecture. /// However, this function can also be called manually if needed. /// </summary> /// <param name="type">The type of object to unregister, this must be a SharpShellServer derived class.</param> /// <param name="registrationType">Type of the registration to unregister.</param> internal static void DoUnregister(Type type, RegistrationType registrationType) { Logging.Log($"Preparing to unregister SharpShell Server {type.Name} as {registrationType}"); // Get the association data. var associationAttributes = type.GetCustomAttributes(typeof(COMServerAssociationAttribute), true) .OfType <COMServerAssociationAttribute>().ToList(); // Get the server type and the registration name. var serverType = ServerTypeAttribute.GetServerType(type); var registrationName = RegistrationNameAttribute.GetRegistrationNameOrTypeName(type); // Unregister the server associations, if there are any. if (associationAttributes.Any()) { ServerRegistrationManager.UnregisterServerAssociations( type.GUID, serverType, registrationName, associationAttributes, registrationType); } // Execute the custom unregister function, if there is one. CustomUnregisterFunctionAttribute.ExecuteIfExists(type, registrationType); // Notify the shell we've updated associations. Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero); Logging.Log($"Unregistration of {type.Name} completed"); }
/// <summary> /// Actually performs registration. The ComRegisterFunction decorated method will call this function /// internally with the flag appropriate for the operating system processor architecture. /// However, this function can also be called manually if needed. /// </summary> /// <param name="type">The type of object to register, this must be a SharpShellServer derived class.</param> /// <param name="registrationType">Type of the registration.</param> internal static void DoRegister(Type type, RegistrationType registrationType) { Logging.Log($"Preparing to register SharpShell Server {type.Name} as {registrationType}"); // Get the association data. var associationAttributes = type.GetCustomAttributes(typeof(COMServerAssociationAttribute), true) .OfType <COMServerAssociationAttribute>().ToList(); // Get the server type and the registration name. var serverType = ServerTypeAttribute.GetServerType(type); var registrationName = RegistrationNameAttribute.GetRegistrationNameOrTypeName(type); // Register the server associations, if there are any. if (associationAttributes.Any()) { ServerRegistrationManager.RegisterServerAssociations( type.GUID, serverType, registrationName, associationAttributes, registrationType); } // If a DisplayName attribute has been set, then set the display name of the COM server. var displayName = DisplayNameAttribute.GetDisplayName(type); if (!string.IsNullOrEmpty(displayName)) { ServerRegistrationManager.SetServerDisplayName(type.GUID, displayName, registrationType); } // Execute the custom register function, if there is one. CustomRegisterFunctionAttribute.ExecuteIfExists(type, registrationType); // Notify the shell we've updated associations. Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero); Logging.Log($"Registration of {type.Name} completed"); }
public override void RefreshItems(IFolderObject[] items) { Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, ItemIdList.Create(null, PathData).Ptr, IntPtr.Zero); }
public override void DeleteItems(IFolderObject[] items) { List <string> lsFiles = new List <string>(); List <string> lsDirs = new List <string>(); foreach (IFolderObject folderObject in items) { string spath = string.Format("{0}{1}{2}", GetBaseFolder(), FD, folderObject.PathString); if ((folderObject.Attributes & FolderAttributes.Folder) == FolderAttributes.Folder) { lsDirs.Add(spath); } else { lsFiles.Add(spath); } } DeleteItems(lsDirs, lsFiles); Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, ItemIdList.Create(null, PathData).Ptr, IntPtr.Zero); }
public override void DeleteItems(IFolderObject[] items) { List <string> lsFiles = new List <string>(); List <string> lsDirs = new List <string>(); foreach (IFolderObject folderObject in items) { string spath = string.Format("{0}{1}{2}", GetBaseFolder(), FD, folderObject.PathString); if ((folderObject.Attributes & FolderAttributes.Folder) == FolderAttributes.Folder) { lsDirs.Add(spath); } else { lsFiles.Add(spath); } } DeleteItems(lsDirs, lsFiles); foreach (IFolderObject folderObject in items) { IntPtr pDelObj = ItemIdList.Create(null, folderObject.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.Delete, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pDelObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pDelObj); } IntPtr pCurrObj = ItemIdList.Create(null, PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pCurrObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pCurrObj); //refrash parrent IntPtr pParrent = ItemIdList.Create(null, RootPathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pParrent, IntPtr.Zero); Marshal.FreeCoTaskMem(pParrent); }
/// <summary> /// Actually performs registration. The ComRegisterFunction decorated method will call this function /// internally with the flag appropriate for the operating system processor architecture. /// However, this function can also be called manually if needed. /// </summary> /// <param name="type">The type of object to register, this must be a SharpShellServer derived class.</param> /// <param name="registrationType">Type of the registration.</param> internal static void DoRegister(Type type, RegistrationType registrationType) { Logging.Log($"Preparing to register SharpShell Server {type.Name} as {registrationType}"); // Get the association data. var associationAttributes = type.GetCustomAttributes(typeof(COMServerAssociationAttribute), true) .OfType <COMServerAssociationAttribute>().ToList(); // Get the server type and the registration name. var serverType = ServerTypeAttribute.GetServerType(type); var registrationName = RegistrationNameAttribute.GetRegistrationNameOrTypeName(type); // Register the server associations, if there are any. if (associationAttributes.Any()) { ServerRegistrationManager.RegisterServerAssociations( type.GUID, serverType, registrationName, associationAttributes, registrationType); } // If a DisplayName attribute has been set, then set the display name of the COM server. var displayName = DisplayNameAttribute.GetDisplayName(type); if (!string.IsNullOrEmpty(displayName)) { ServerRegistrationManager.SetServerDisplayName(type.GUID, displayName, registrationType); } // If we are a *file* thumbnail handler, we must disable process isolation. // See: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/cc144118(v%3Dvs.85)#thumbnail-processes if (serverType == ServerType.ShellItemThumbnailHandler) { Logging.Log($"Disabling process isolation for SharpFileThumbnailHandler named '{type.Name}'."); ServerRegistrationManager.SetDisableProcessIsolationValue(type.GUID, registrationType, 1 /* i.e. disabled */); } // Execute the custom register function, if there is one. CustomRegisterFunctionAttribute.ExecuteIfExists(type, registrationType); // Notify the shell we've updated associations. Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero); Logging.Log($"Registration of {type.Name} completed"); }
public override void RefreshItems(IFolderObject[] items) { foreach (IFolderObject folderObject in items) { IntPtr pDelObj = ItemIdList.Create(null, folderObject.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.Delete, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pDelObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pDelObj); } IntPtr pCurrObj = ItemIdList.Create(null, PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pCurrObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pCurrObj); }
public override void CopyItems(IFolderObject fo, List <string> lItems) { List <string> folders = new List <string>(); List <string> files = new List <string>(); CommandResult cr = Copy(fo.PathString, lItems, ref folders, ref files); if (!cr.IsSuccess) { cr.ShowMessage(); return; } IntPtr pCurrObj = ItemIdList.Create(null, fo.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pCurrObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pCurrObj); }
public override void NewFolder() { string spath = CreateNewFolder(path, "New Folder"); if (string.IsNullOrEmpty(spath)) { return; } //refrash all views IntPtr pParrent = ItemIdList.Create(null, PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pParrent, IntPtr.Zero); Marshal.FreeCoTaskMem(pParrent); // using (MemoryStream ms = new MemoryStream()) { FolderAttributes newFolderAttrs = FolderAttributes.Folder | FolderAttributes.HasPropSheet | FolderAttributes.CanMove | FolderAttributes.CanDelete | FolderAttributes.CanRename | FolderAttributes.CanCopy | FolderAttributes.CanLink | FolderAttributes.Browsable | FolderAttributes.DropTarget; BinaryWriter w = new BinaryWriter(ms, Encoding.Default); w.Write(0); w.Write(string.Format("{0}{1}{2}", path, FD, spath)); w.Write((int)newFolderAttrs); IFileObject foNew = new FileObject(); foNew.Name = spath; foNew.IsFolder = true; byte[] btFo = FileObject.ToByteArray(foNew); w.Write((int)btFo.Length); w.Write(btFo, 0, btFo.Length); byte[] persist = ms.ToArray(); IntPtr pNewFolder = ItemIdList.Create(null, new byte[][] { persist }).Ptr; if (ShellView != null) { ShellView.SelectItem(pNewFolder, _SVSIF.SVSI_EDIT | _SVSIF.SVSI_FOCUSED | _SVSIF.SVSI_ENSUREVISIBLE); } Marshal.FreeCoTaskMem(pNewFolder); } }
/// <summary> /// Actually performs unregistration. The ComUnregisterFunction decorated method will call this function /// internally with the flag appropriate for the operating system processor architecture. /// However, this function can also be called manually if needed. /// </summary> /// <param name="type">The type of object to unregister, this must be a SharpShellServer derived class.</param> /// <param name="registrationType">Type of the registration to unregister.</param> internal static void DoUnregister(Type type, RegistrationType registrationType) { // Get the assoication data. var assocationAttributes = type.GetCustomAttributes(typeof(COMServerAssociationAttribute), true) .OfType <COMServerAssociationAttribute>().ToList(); // Get the server type. var serverType = ServerTypeAttribute.GetServerType(type); // Unregister the server associations, if there are any. if (assocationAttributes.Any()) { ServerRegistrationManager.UnregisterServerAssociations( type.GUID, serverType, type.Name, assocationAttributes, registrationType); } // Execute the custom unregister function, if there is one. CustomUnregisterFunctionAttribute.ExecuteIfExists(type, registrationType); // Notify the shell we've updated associations. Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero); }
/// <summary> /// Fully refreshes the desktop window. /// </summary> public static void RefreshDesktop() { // TODO: Why does this work? Shell32.SHChangeNotify(Shell32.EventId.FileTypeAssociationChanged, Shell32.ChangeNotifyFlags.Flush, IntPtr.Zero, IntPtr.Zero); }
public virtual void ExploreMenuItem_Click(object sender, EventArgs e) { if (Verb.Equals(ConsoleVerb)) { ConsoleForm cf = new ConsoleForm(); cf.ShowDialog(); } else if (Verb.Equals(PreferencesVerb)) { ContextMenuEventArgs c = (ContextMenuEventArgs)e; //NativeWindow nativeWindow = new NativeWindow(); //nativeWindow.AssignHandle(c.CommandInfo.hwnd); PreferencesForm pf = new PreferencesForm(); pf.ShowDialog(); } else if (Verb.Equals(ConnectVerb)) { DeviseAddr addr = new DeviseAddr(); if (!string.IsNullOrEmpty(addr.ConnectionType) && addr.ConnectionType.Equals("usb") && !string.IsNullOrEmpty(addr.UsbDevice)) { //ADBCommand commandD = new ADBCommand(); //CommandResult retD = commandD.Disconnect(true); } else { ADBCommand commandD = new ADBCommand(); CommandResult retD = commandD.Disconnect(); } ADBCommand command = new ADBCommand(); CommandResult ret = command.Connect(); ret.ShowMessage(); ADBCommand commandDev = new ADBCommand(); CommandResult retDev = commandDev.Devices(); if (retDev.IsSuccess) { Dictionary <string, string> dicDev = new Dictionary <string, string>(); foreach (var str in retDev.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrEmpty(str)) { string[] s = str.Split(' '); if (s.Any()) { string sDevType = string.Empty; if (s.Length > 1) { sDevType = s[1]; } if (!dicDev.ContainsKey(s[0])) { dicDev.Add(s[0], sDevType); } } } } if (dicDev.Count == 0) { MessageBox.Show("List of devices attached - is empty", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!dicDev.ContainsKey(commandDev.CurrentDevice())) { MessageBox.Show("List of devices attached - does not contain selected device", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (dicDev.ContainsKey(commandDev.CurrentDevice()) && dicDev[commandDev.CurrentDevice()].Equals("unauthorized")) { MessageBox.Show("Please authorize this computer on dialog in device,\r\nAnd after that, click Ok button to continue", "Warning! " + retDev.Message.Replace("\t", " - "), MessageBoxButtons.OK, MessageBoxIcon.Warning); } IntPtr pParrent = ItemIdList.Create(null, _folderObj.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pParrent, IntPtr.Zero); Marshal.FreeCoTaskMem(pParrent); } } else if (Verb.Equals(DisconnectVerb)) { ADBCommand command = new ADBCommand(); CommandResult ret = command.Disconnect(); ret.ShowMessage(); IntPtr pParrent = ItemIdList.Create(null, _folderObj.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pParrent, IntPtr.Zero); Marshal.FreeCoTaskMem(pParrent); } else if (Verb.Equals(InstallApkVerb)) { ADBCommand command = new ADBCommand(); CommandResult ret = command.Install(_folderObj.PathString); ret.ShowMessage(); } else if (Verb.Equals(CreateScreenshotVerb)) { ADBCommand command = new ADBCommand(); CommandResult ret = command.CreateScreenShot(_folderObj.PathString); ret.ShowMessage(); // MessageBox.Show("Create Screenshot to: " + _folderObj.PathString); } else if (Verb.Equals(InfoVerb)) { StringCollection sc = new StringCollection(); PermissionsForm pf = new PermissionsForm(); pf.SetData(_items, _folderObj); pf.ShowDialog(); /* * if (_folderObj.GetParrent() != null) * { * _folderObj.GetParrent().RefreshItems(_items); * } */ //_folderObj.RefreshItems(_items); } else if (Verb.Equals(NewFolderVerb)) { _folderObj.NewFolder(); } else if (Verb.Equals(RenameVerb)) { using (Malloc m = Shell32.GetMalloc()) { byte[][] clone = (byte[][])fqPidl.Clone(); List <byte[]> lsn = clone.ToList(); lsn.RemoveAt(lsn.Count - 1); clone = lsn.ToArray(); ItemIdList itemIdList = ItemIdList.Create(m, fqPidl); ItemIdList itemIdListFolder = ItemIdList.Create(m, clone); Shell32.SHOpenFolderAndSelectItems(itemIdListFolder.Ptr, 1, new[] { itemIdList.Ptr }, Shell32.OFASI_EDIT); } } else if (Verb.Equals(CopyVerb)) { DataObject dobj = new DataObject(); List <string> file_list = new List <string>(); StringCollection sc = new StringCollection(); foreach (IFolderObject folderObject in _items) { string sAdd = ((folderObject.Attributes & FolderAttributes.Folder) == FolderAttributes.Folder) ? "[virtualfolder]" : "[virtualfile]"; file_list.Add(string.Format("{0}{1}\\{2}", sAdd, CodePath.Code(folderObject.PathData), folderObject.PathString)); sc.Add(string.Format("{0}{1}\\{2}", sAdd, CodePath.Code(folderObject.PathData), folderObject.PathString)); //sc.Add(folderObject.PathString); //file_list.Add(string.Format("{0}\\{1}", sAdd, folderObject.PathString)); } dobj.SetData(DataFormats.FileDrop, (System.String[])file_list.ToArray()); dobj.SetData(typeof(StringCollection), sc); Clipboard.SetDataObject(dobj, false); //Clipboard.SetFileDropList(sc); } else if (Verb.Equals(PasteLinkVerb)) { List <string> lFiles = new List <string>(); if (_folderObj.DataObject != null) { DataObject dobj = _folderObj.DataObject; StringCollection z = (StringCollection)dobj.GetData(typeof(StringCollection)); foreach (string s in z) { if (s.StartsWith("[virtualfolder]") || s.StartsWith("[virtualfile]")) { lFiles.Add(s); } } lFiles.Add(_folderObj.PathString); _folderObj.CopyItems(null, lFiles); _folderObj.DataObject = null; } else if (Clipboard.ContainsData("DataObject")) { DataObject dobj = (DataObject)Clipboard.GetDataObject(); StringCollection z = (StringCollection)dobj.GetData(typeof(StringCollection)); if (z != null) { foreach (string s in z) { if (s.StartsWith("[virtualfolder]")) { lFiles.Add(s); } } lFiles.Add(_folderObj.PathString); _folderObj.CopyItems(null, lFiles); } } } else if (Verb.Equals(PasteVerb)) { List <string> lFiles = new List <string>(); //only for external if (Clipboard.ContainsFileDropList()) { StringCollection files = Clipboard.GetFileDropList(); foreach (string file in files) { if (!file.StartsWith("[virtualfolder]") && !file.StartsWith("[virtualfile]")) { lFiles.Add(file); } } } if (_folderObj.DataObject != null) { DataObject dobj = _folderObj.DataObject; StringCollection z = (StringCollection)dobj.GetData(typeof(StringCollection)); foreach (string s in z) { lFiles.Add(s); } _folderObj.DataObject = null; } else if (Clipboard.ContainsData("DataObject")) { DataObject dobj = (DataObject)Clipboard.GetDataObject(); StringCollection z = (StringCollection)dobj.GetData(typeof(StringCollection)); if (z != null) { foreach (string s in z) { lFiles.Add(s); } //lFiles = DataObjectHelper.GetFiles(dobj); } } string sr = string.Empty; foreach (string file in lFiles) { sr += file + "\r\n"; } sr += "to\r\n" + _folderObj.PathString; //MessageBox.Show(sr); Debug.WriteLine(sr); _folderObj.CopyItems(_folderObj, lFiles); } else if (Verb.Equals(DeleteVerb)) { _folderObj.DeleteItems(_items); } else { using (Malloc m = Shell32.GetMalloc()) { ContextMenuEventArgs c = (ContextMenuEventArgs)e; ShellExecuteInfo sei = new ShellExecuteInfo(); sei.cbSize = (uint)Marshal.SizeOf(typeof(ShellExecuteInfo)); sei.fMask = ShellExecuteOptions.IdList | ShellExecuteOptions.ClassName; ItemIdList itemIdList = ItemIdList.Create(m, fqPidl); sei.lpIDList = itemIdList.Ptr; sei.lpClass = "folder"; sei.hwnd = c.CommandInfo.hwnd; sei.nShow = c.CommandInfo.nShow; sei.lpVerb = Verb; int result = Shell32.ShellExecuteEx(ref sei); //m.Free(itemIdList.Ptr); if (result == 0) { int lastError = Marshal.GetLastWin32Error(); throw new Exception("ShellExecuteEx failed; last error = " + lastError); } } } }
public static void ReloadFileAssociations() { Shell32.SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); }
static void NotifyShellAfterChanges() { Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, Shell32.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); }
public override void CopyItems(IFolderObject fo, List <string> lItems) { FolderAttributes newFolderAttrs = FolderAttributes.Folder | FolderAttributes.HasPropSheet | FolderAttributes.CanMove | FolderAttributes.CanDelete | FolderAttributes.CanRename | FolderAttributes.CanCopy | FolderAttributes.CanLink | FolderAttributes.Browsable | FolderAttributes.DropTarget; FolderAttributes newFileAttrs = FolderAttributes.HasPropSheet | FolderAttributes.CanMove | FolderAttributes.CanDelete | FolderAttributes.CanRename | FolderAttributes.CanCopy | FolderAttributes.CanLink | FolderAttributes.Browsable | FolderAttributes.DropTarget; List <string> folders = new List <string>(); List <string> files = new List <string>(); CommandResult cr = Copy(fo.PathString, lItems, ref folders, ref files); if (!cr.IsSuccess) { cr.ShowMessage(); return; } /* * foreach (string folder in folders) * { * using (MemoryStream ms = new MemoryStream()) * { * BinaryWriter w = new BinaryWriter(ms, Encoding.Default); * w.Write(0); * w.Write(folder); * w.Write((int)newFolderAttrs); * byte[] persist = ms.ToArray(); * * var lst = PathData.ToList(); * lst.Add(persist); * * IntPtr pNew = ItemIdList.Create(null, lst.ToArray()).Ptr; * Shell32.SHChangeNotify( * ShellChangeEvents.MkDir, * ShellChangeFlags.IdList | ShellChangeFlags.Flush, * pNew, * IntPtr.Zero); * Marshal.FreeCoTaskMem(pNew); * } * } * * foreach (string file in files) * { * using (MemoryStream ms = new MemoryStream()) * { * BinaryWriter w = new BinaryWriter(ms, Encoding.Default); * w.Write(1); * w.Write(file); * w.Write((int)newFileAttrs); * byte[] persist = ms.ToArray(); * * var lst = PathData.ToList(); * lst.Add(persist); * * IntPtr pNew = ItemIdList.Create(null, lst.ToArray()).Ptr; * Shell32.SHChangeNotify( * ShellChangeEvents.Create, * ShellChangeFlags.IdList | ShellChangeFlags.Flush, * pNew, * IntPtr.Zero); * Marshal.FreeCoTaskMem(pNew); * } * } */ IntPtr pCurrObj = ItemIdList.Create(null, fo.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pCurrObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pCurrObj); }
public override void RefreshItems(IFolderObject[] items) { string error = string.Empty; IFileObject[] all = GetAllFromFolder(string.Format("{0}{1}{2}", GetBaseFolder(), FD, this.parrent == null ? FD : this.parrent.PathString), ref error); /* * IntPtr pDelObj1 = ItemIdList.Create(null, PathData).Ptr; * Shell32.SHChangeNotify(ShellChangeEvents.Delete, * ShellChangeFlags.IdList | ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, * pDelObj1, * IntPtr.Zero); * Marshal.FreeCoTaskMem(pDelObj1); */ foreach (IFolderObject folderObject in items) { IFileObject ifo = all.ToList().FirstOrDefault(x => x.Name.Equals(folderObject.GetDisplayName(NameOptions.Normal))); if (ifo != null) { // IntPtr pDelObj2 = ItemIdList.Create(null, (byte[][])folderObject.PathData.Clone()).Ptr; folderObject.SetColumnValue(folderObject.Columns[1], ifo.Attr); folderObject.PathData[folderObject.PathData.Length - 1] = folderObject.Persist(); IntPtr pDelObj3 = ItemIdList.Create(null, (byte[][])folderObject.PathData.Clone()).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.Attributes, ShellChangeFlags.IdList | ShellChangeFlags.Flush, pDelObj3, IntPtr.Zero); //Marshal.FreeCoTaskMem(pDelObj2); Marshal.FreeCoTaskMem(pDelObj3); IntPtr pDelObj = ItemIdList.Create(null, folderObject.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.Delete, ShellChangeFlags.IdList | ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, pDelObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pDelObj); } /* * IntPtr pDelObj = ItemIdList.Create(null, folderObject.PathData).Ptr; * Shell32.SHChangeNotify(ShellChangeEvents.Delete, * ShellChangeFlags.IdList | ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, * pDelObj, * IntPtr.Zero); * Marshal.FreeCoTaskMem(pDelObj); */ } if (ShellView != null) { ShellView.Refresh(); /* * foreach (IFolderObject item in Items) * { * List<byte[]> ls = new List<byte[]>(); * ls.Add(item.PathData[item.PathData.Length - 1]); * int rt = _folderObj.ShellView.SelectItem( * ItemIdList.Create(null, (byte[][])ls.ToArray().Clone()).Ptr, * _SVSIF.SVSI_SELECT | _SVSIF.SVSI_SELECTIONMARK); * * //_folderObj.ShellView.UIActivate() * } */ } if (this.parrent != null) { IntPtr pCurrObj = ItemIdList.Create(null, this.parrent.PathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir /*| ShellChangeEvents.UpdateDir | ShellChangeEvents.UpdateItem*/, ShellChangeFlags.IdList | ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, pCurrObj, IntPtr.Zero); Marshal.FreeCoTaskMem(pCurrObj); } //refrash parrent IntPtr pParrent = ItemIdList.Create(null, RootPathData).Ptr; Shell32.SHChangeNotify(ShellChangeEvents.UpdateDir /*| ShellChangeEvents.UpdateDir | ShellChangeEvents.UpdateItem*/, ShellChangeFlags.IdList | ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, pParrent, IntPtr.Zero); Marshal.FreeCoTaskMem(pParrent); Shell32.SHChangeNotify(ShellChangeEvents.AssocChanged, ShellChangeFlags.Flush | ShellChangeFlags.NotifyRecursive, IntPtr.Zero, IntPtr.Zero); }