Esempio n. 1
0
        private void WorkThread()
        {
            mi_WaitForm.SetLabelText("Moving to recycler...");

            const int  FO_DELETE         = 0x0003;
            const int FOF_SILENT         = 0x0004;
            const int FOF_ALLOWUNDO      = 0x0040;
            const int FOF_NOERRORUI      = 0x0400;
            const int FOF_NOCONFIRMATION = 0x0010;

            Functions.RemoveWriteProtection(ms_File);

            uint u32_Flags = FOF_ALLOWUNDO |     // move to recycle bin
                             FOF_SILENT    |     // don't show progress bar
                             FOF_NOERRORUI |     // don't show error MessageBoxes
                             FOF_NOCONFIRMATION; // don't ask for confirmation

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                SHFILEOPSTRUCTW k_File = new SHFILEOPSTRUCTW();
                k_File.hwnd   = IntPtr.Zero;         // not used
                k_File.wFunc  = FO_DELETE;
                k_File.pFrom  = ms_File + "\0";      // requires !TWO! terminating zeroes
                k_File.pTo    = null;
                k_File.fFlags = u32_Flags;

                ms32_Error = SHFileOperationW(ref k_File);
            }
            else
            {
                SHFILEOPSTRUCTA k_File = new SHFILEOPSTRUCTA();
                k_File.hwnd   = IntPtr.Zero;         // not used
                k_File.wFunc  = FO_DELETE;
                k_File.pFrom  = ms_File + "\0";      // requires !TWO! terminating zeroes
                k_File.pTo    = null;
                k_File.fFlags = u32_Flags;

                ms32_Error = SHFileOperationA(ref k_File);
            }

            mi_WaitForm.Close(); // DialogResult.OK
        }
Esempio n. 2
0
 static extern int SHFileOperationW(ref SHFILEOPSTRUCTW k_FileOp);