public static bool DeleteFile(List <string> lstPaths, bool fShiftKey, IntPtr hwnd) { string s = MakeFILEOPPATHS(lstPaths); if (s.Length > 1) { SHFILEOPSTRUCT lpFileOp = new SHFILEOPSTRUCT(); lpFileOp.hwnd = hwnd; lpFileOp.wFunc = 3; lpFileOp.pFrom = Marshal.StringToHGlobalUni(s); lpFileOp.fFlags = fShiftKey ? ((short)0x4000) : ((short)0x40); try { if (PInvoke.SHFileOperation(ref lpFileOp) == 0) { return(!lpFileOp.fAnyOperationsAborted); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); } finally { if (lpFileOp.pFrom != IntPtr.Zero) { Marshal.FreeHGlobal(lpFileOp.pFrom); } } } return(false); }
public static bool DeleteFile(List <string> lstPaths, bool fShiftKey, IntPtr hwnd) { string s = MakeFILEOPPATHS(lstPaths); if (s.Length > 1) { using (SafePtr pFrom = new SafePtr(s)) { SHFILEOPSTRUCT lpFileOp = new SHFILEOPSTRUCT { hwnd = hwnd, wFunc = 3, pFrom = pFrom, fFlags = fShiftKey ? ((short)0x4000) : ((short)0x40) }; try { if (PInvoke.SHFileOperation(ref lpFileOp) == 0) { return(!lpFileOp.fAnyOperationsAborted); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } } } return(false); }
public static bool PasteFile(string pathTarget, IntPtr hwnd) { try { List <string> paths = ClipboardGetFileDropList(hwnd); if (paths.Count == 0) { return(false); } string s = MakeFILEOPPATHS(paths); if (s.Length > 1) { bool flag; if (pathTarget.Length != 3) { pathTarget = pathTarget.TrimEnd(new char[] { '\\' }); } pathTarget = GetTargetIfFolderLink(new DirectoryInfo(pathTarget), out flag).FullName; if (flag) { bool prefferdDropEffect = GetPrefferdDropEffect(hwnd); short num = 0x40; if (IsTargetPathContained(paths, pathTarget)) { num = (short)(num | 8); } SHFILEOPSTRUCT lpFileOp = new SHFILEOPSTRUCT(); lpFileOp.hwnd = hwnd; lpFileOp.wFunc = prefferdDropEffect ? 1 : 2; lpFileOp.pFrom = Marshal.StringToHGlobalUni(s); lpFileOp.pTo = Marshal.StringToHGlobalUni(pathTarget + '\0'); lpFileOp.fFlags = num; try { if (PInvoke.SHFileOperation(ref lpFileOp) == 0) { return(!lpFileOp.fAnyOperationsAborted); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); } finally { if (lpFileOp.pFrom != IntPtr.Zero) { Marshal.FreeHGlobal(lpFileOp.pFrom); } if (lpFileOp.pTo != IntPtr.Zero) { Marshal.FreeHGlobal(lpFileOp.pTo); } } } } } catch (Exception exception2) { QTUtility2.MakeErrorLog(exception2, null); } return(false); }
public static int ListView_HitTest(IntPtr hwnd, IntPtr lParam) { LVHITTESTINFO structure = new LVHITTESTINFO { pt = QTUtility2.PointFromLPARAM(lParam) }; int num = (int)SendMessage(hwnd, 0x1012, IntPtr.Zero, ref structure); return(num); }
public static bool PasteFile(string pathTarget, IntPtr hwnd) { try { List <string> paths = ClipboardGetFileDropList(hwnd); if (paths.Count == 0) { return(false); } string s = MakeFILEOPPATHS(paths); if (s.Length > 1) { bool flag; if (pathTarget.Length != 3) { pathTarget = pathTarget.TrimEnd(new char[] { '\\' }); } pathTarget = GetTargetIfFolderLink(new DirectoryInfo(pathTarget), out flag).FullName; if (flag) { bool prefferdDropEffect = GetPrefferdDropEffect(hwnd); short num = 0x40; if (IsTargetPathContained(paths, pathTarget)) { num = (short)(num | 8); } using (SafePtr pFrom = new SafePtr(s)) using (SafePtr pTo = new SafePtr(pathTarget + '\0')) { SHFILEOPSTRUCT lpFileOp = new SHFILEOPSTRUCT { hwnd = hwnd, wFunc = prefferdDropEffect ? 1 : 2, pFrom = pFrom, pTo = pTo, fFlags = num }; try { if (PInvoke.SHFileOperation(ref lpFileOp) == 0) { return(!lpFileOp.fAnyOperationsAborted); } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception); } } } } } catch (Exception exception2) { QTUtility2.MakeErrorLog(exception2, null); } return(false); }
public static int ListView_HitTest(IntPtr hwnd, IntPtr lParam) { LVHITTESTINFO structure = new LVHITTESTINFO(); structure.pt = QTUtility2.PointFromLPARAM(lParam); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); int num = (int)SendMessage(hwnd, 0x1012, IntPtr.Zero, ptr); Marshal.FreeHGlobal(ptr); return(num); }
public static int ListView_HitTest(IntPtr hwnd, IntPtr lParam) { QTTabBarLib.Interop.LVHITTESTINFO structure = new QTTabBarLib.Interop.LVHITTESTINFO(); structure.pt.x = QTUtility2.GET_X_LPARAM(lParam); structure.pt.y = QTUtility2.GET_Y_LPARAM(lParam); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); int num = (int)SendMessage(hwnd, 0x1012, IntPtr.Zero, ptr); Marshal.FreeHGlobal(ptr); return(num); }
public static string GetShellInfoTipText(IntPtr pIDL, bool fAllowSlow) { if (pIDL != IntPtr.Zero) { IShellFolder ppv = null; IQueryInfo o = null; try { IntPtr ptr; if (PInvoke.SHBindToParent(pIDL, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr) == 0) { Guid riid = ExplorerGUIDs.IID_IQueryInfo; IntPtr[] apidl = new IntPtr[] { ptr }; uint rgfReserved = 0; object obj2; if (ppv.GetUIObjectOf(IntPtr.Zero, 1, apidl, ref riid, ref rgfReserved, out obj2) == 0) { string str; o = obj2 as IQueryInfo; if ((o != null) && (o.GetInfoTip(fAllowSlow ? 8 : 0, out str) == 0)) { return(str); } } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, null); } finally { if (ppv != null) { Marshal.ReleaseComObject(ppv); } if (o != null) { Marshal.ReleaseComObject(o); } } } return(null); }
public static int PopUpSystemContextMenu(IDLWrapper idlw, Point pntShow, ref IContextMenu2 pIContextMenu2, IntPtr hwndParent, bool fCanRemove) { IShellFolder ppv = null; int num5; try { IntPtr ptr; if ((!idlw.Available || (PInvoke.SHBindToParent(idlw.PIDL, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr) != 0)) || (ppv == null)) { return(-1); } IntPtr[] apidl = new IntPtr[] { ptr }; uint rgfReserved = 0; Guid riid = ExplorerGUIDs.IID_IContextMenu; object obj2; ppv.GetUIObjectOf(IntPtr.Zero, (uint)apidl.Length, apidl, ref riid, ref rgfReserved, out obj2); if (pIContextMenu2 != null) { Marshal.ReleaseComObject(pIContextMenu2); pIContextMenu2 = null; } pIContextMenu2 = obj2 as IContextMenu2; if (pIContextMenu2 == null) { return(-2); } ContextMenu menu = new ContextMenu(); uint uFlags = 0; if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { uFlags |= 0x100; } pIContextMenu2.QueryContextMenu(menu.Handle, 0, 1, 0xffff, uFlags); if (fCanRemove) { PInvoke.AppendMenu(menu.Handle, 0x800, IntPtr.Zero, null); PInvoke.AppendMenu(menu.Handle, 0, new IntPtr(0xffff), QTUtility.ResMain[0x19]); } if ((idlw.HasPath && (idlw.Path.Length > 3)) && (idlw.IsFileSystemFolder || idlw.IsFileSystemFile)) { if (!fCanRemove) { PInvoke.AppendMenu(menu.Handle, 0x800, IntPtr.Zero, null); } PInvoke.AppendMenu(menu.Handle, 0, new IntPtr(0xfffe), QTUtility.ResMain[0x1a]); } uint num3 = PInvoke.TrackPopupMenu(menu.Handle, 0x100, pntShow.X, pntShow.Y, 0, hwndParent, IntPtr.Zero); int num4 = -3; switch (num3) { case 0: num4 = 0xfffd; break; case 0xffff: menu.Dispose(); return(0xffff); case 0xfffe: if (idlw.HasPath) { try { string directoryName = Path.GetDirectoryName(idlw.Path); if (Directory.Exists(directoryName)) { IntPtr currentHandle = QTUtility.instanceManager.CurrentHandle; if (PInvoke.IsWindow(currentHandle)) { QTUtility2.SendCOPYDATASTRUCT(currentHandle, (IntPtr)0x10, directoryName, IntPtr.Zero); num4 = 0xfffe; } else { Process.Start(directoryName); num4 = -4; } } } catch { SystemSounds.Asterisk.Play(); } } break; default: { CMINVOKECOMMANDINFO structure = new CMINVOKECOMMANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 0; structure.hwnd = hwndParent; structure.lpVerb = (IntPtr)((num3 - 1) & 0xffff); structure.lpParameters = IntPtr.Zero; structure.lpDirectory = IntPtr.Zero; structure.nShow = 1; structure.dwHotKey = 0; structure.hIcon = IntPtr.Zero; num4 = pIContextMenu2.InvokeCommand(ref structure); break; } } menu.Dispose(); num5 = num4; } catch { num5 = -1; } finally { if (ppv != null) { Marshal.ReleaseComObject(ppv); } } return(num5); }