$INCLUDE "QSHFileOperation.inc"
CONST TRUE = 1
CONST FALSE = 0
CONST NULL = FALSE
DECLARE SUB FOp
DECLARE SUB FOpEnd
DIM Form AS QFORM
Form.CAPTION = "SHFileOperation sample"
Form.Width = Form.Width / 1.4
Form.Height = Form.Height * 1.35
DIM RichEdit AS QRICHEDIT
RichEdit.PARENT = Form
RichEdit.Align = 5
RichEdit.AddStrings("Press any key...")
RichEdit.OnChange = FOp
DIM FileOp AS QSHFileOperation
FileOp.DefaultFlagsEx = fofSimpleProgress OR fofNoConfirmMkDir OR fofRenameOnCollision
Form.SHOWMODAL
SUB FOp
counter++
SELECT CASE counter
CASE 1
RichEdit.Clear
SHfoResult = FileOp.CopyEx("c:\autoexec.bat","c:\temp_dir1\autoexec.bat",fofSimpleProgress,NULL)
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Copying 1 made", " Press any key...")
ELSE
RichEdit.AddStrings("Copying 1 failed", " Press any key...")
END IF
CASE 2
SHfoResult = FileOp.Copy("c:\config.sys","c:\temp_dir1\config.sys")
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Copying 2 made", " Press any key...")
ELSE
RichEdit.AddStrings("Copying 2 failed", " Press any key...")
END IF
CASE 3
FileOp.DefaultFlagsEx = 0
FileOp.DefaultFlagsEx = fofSimpleProgress
SHfoResult = FileOp.CopyEx("c:\temp_dir1\*.*","c:\temp_dir2",NULL,NULL)
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Copying 3 made", " Press any key...")
ELSE
RichEdit.AddStrings("Copying 3 failed", " Press any key...")
END IF
CASE 4
SHfoResult = FileOp.RENAME("c:\temp_dir1","c:\temp_dir3")
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Renaming made", " Press any key...")
ELSE
RichEdit.AddStrings("Renaming failed", " Press any key...")
END IF
CASE 5
SHfoResult = FileOp.Delete("c:\temp_dir2",TRUE,FALSE)
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Deleting 1 (to Bin) made", " Press any key...")
ELSE
RichEdit.AddStrings("Deleting 1 (to Bin) failed", " Press any key...")
END IF
CASE 6
SHfoResult = FileOp.Delete("c:\temp_dir3",FALSE,TRUE)
IF SHfoResult = 0 THEN
RichEdit.AddStrings("Deleting 2 made", " Press any key...")
ELSE
RichEdit.AddStrings("Deleting 2 failed", " Press any key...")
END IF
RichEdit.AddStrings("", "-----", "Finnish - remove files from Bin..."," Press any key to exit...")
RichEdit.OnChange = FOpEnd
END SELECT
END SUB
SUB FOpEnd
END
END SUB
|