Ejemplo n.º 1
0
        public static int SHFileOperation(ref SHFILEOPSTRUCT lpFileOp)
        {
            if (IntPtr.Size == 4)
            {
                return(SHFileOperation32(ref lpFileOp));
            }
            SHFILEOPSTRUCT64 shfileopstruct = new SHFILEOPSTRUCT64();

            shfileopstruct.hwnd   = lpFileOp.hwnd;
            shfileopstruct.wFunc  = lpFileOp.wFunc;
            shfileopstruct.pFrom  = lpFileOp.pFrom;
            shfileopstruct.pTo    = lpFileOp.pTo;
            shfileopstruct.fFlags = lpFileOp.fFlags;
            shfileopstruct.fAnyOperationsAborted = lpFileOp.fAnyOperationsAborted;
            shfileopstruct.hNameMappings         = lpFileOp.hNameMappings;
            shfileopstruct.lpszProgressTitle     = lpFileOp.lpszProgressTitle;
            int num = SHFileOperation64(ref shfileopstruct);

            lpFileOp.fAnyOperationsAborted = shfileopstruct.fAnyOperationsAborted;
            return(num);
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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 = QTTabBarClass.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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 private static extern int SHFileOperation32(ref SHFILEOPSTRUCT lpFileOp);
Ejemplo n.º 6
0
 public static int SHFileOperation(ref SHFILEOPSTRUCT lpFileOp) {
     if(IntPtr.Size == 4) {
         return SHFileOperation32(ref lpFileOp);
     }
     SHFILEOPSTRUCT64 shfileopstruct = new SHFILEOPSTRUCT64();
     shfileopstruct.hwnd = lpFileOp.hwnd;
     shfileopstruct.wFunc = lpFileOp.wFunc;
     shfileopstruct.pFrom = lpFileOp.pFrom;
     shfileopstruct.pTo = lpFileOp.pTo;
     shfileopstruct.fFlags = lpFileOp.fFlags;
     shfileopstruct.fAnyOperationsAborted = lpFileOp.fAnyOperationsAborted;
     shfileopstruct.hNameMappings = lpFileOp.hNameMappings;
     shfileopstruct.lpszProgressTitle = lpFileOp.lpszProgressTitle;
     int num = SHFileOperation64(ref shfileopstruct);
     lpFileOp.fAnyOperationsAborted = shfileopstruct.fAnyOperationsAborted;
     return num;
 }
Ejemplo n.º 7
0
 private static extern int SHFileOperation32(ref SHFILEOPSTRUCT lpFileOp);
Ejemplo n.º 8
0
 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;
 }