$TYPECHECK ON
CONST foMove = &H1
CONST foCopy = &H2
CONST foDelete = &H3
CONST foRename = &H4
CONST fofAllowUndo = &H40
CONST fofConfirmMouse = &H2
CONST fofFilesOnly = &H80
CONST fofMultiDestFiles = &H1
CONST fofNoConnectedElements = &H2000
CONST fofNoConfirmation = &H10
CONST fofNoConfirmMkDir = &H200
CONST fofNoCopySecurityAttribs = &H800
CONST fofNoErrorUI = &H400
CONST fofNoRecursion = &H1000
CONST fofRenameOnCollision = &H8
CONST fofSilent = &H4
CONST fofSimpleProgress = &H100
CONST fofWantNukeWarning = &H4000
TYPE SHFILEOPSTRUCT
hwnd AS LONG
wFunc AS LONG
pFrom AS LONG
pTo AS LONG
fFlags AS INTEGER
fAnyOperationsAborted AS LONG
hNameMappings AS LONG
lpszProgressTitle AS LONG
END TYPE
DECLARE FUNCTION SHFileOperation LIB "shell32.dll" _
ALIAS "SHFileOperationA" (lpFileOp AS SHFILEOPSTRUCT) AS LONG
DIM lpFileOp AS SHFILEOPSTRUCT
DEFSTR SHfoFrom, dSHfoFrom, SHfoTo, dSHfoTo
TYPE QSHFileOperation EXTENDS QOBJECT
Private:
SUB ClearSHFileOperationStructure
lpFileOp.hwnd = 0
lpFileOp.wFunc = 0
lpFileOp.pFrom = 0
lpFileOp.pTo = 0
lpFileOp.fFlags = 0
END SUB
Public:
DefaultFlagsEx AS INTEGER
DefaultFlags AS INTEGER
CONSTRUCTOR
DefaultFlagsEx = 0
DefaultFlags = fofRenameOnCollision
END CONSTRUCTOR
FUNCTION CopyEx (dSHfoFrom AS STRING, dSHfoTo AS STRING, _
SHfoFlags AS INTEGER, SHfoHandle AS LONG) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.hwnd = SHfoHandle
lpFileOp.wFunc = foCopy
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlagsEx OR SHfoFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION Copy (dSHfoFrom AS STRING, dSHfoTo AS STRING) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.wFunc = foCopy
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION MoveEx (dSHfoFrom AS STRING, dSHfoTo AS STRING, _
SHfoFlags AS INTEGER, SHfoHandle AS LONG) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.hwnd = SHfoHandle
lpFileOp.wFunc = foMove
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlagsEx OR SHfoFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION Move (dSHfoFrom AS STRING, dSHfoTo AS STRING) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.wFunc = foMove
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION RenameEx (dSHfoFrom AS STRING, dSHfoTo AS STRING, _
SHfoFlags AS INTEGER, SHfoHandle AS LONG) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.hwnd = SHfoHandle
lpFileOp.wFunc = foRename
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlagsEx OR SHfoFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION RENAME (dSHfoFrom AS STRING, dSHfoTo AS STRING) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
SHfoTo = dSHfoTo & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.wFunc = foRename
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.pTo = VARPTR(SHfoTo)
lpFileOp.fFlags = QSHFileOperation.DefaultFlags
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION DeleteEx (dSHfoFrom AS STRING, SHfoToBin AS INTEGER, SHConfirm AS INTEGER, _
SHfoFlags AS INTEGER, SHfoHandle AS LONG) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.hwnd = SHfoHandle
lpFileOp.wFunc = foDelete
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.fFlags = QSHFileOperation.DefaultFlagsEx OR SHfoFlags OR (fofAllowUndo * SHfoToBin) OR (fofNoConfirmation * ABS(SHConfirm - 1))
Result = SHFileOperation(lpFileOp)
END FUNCTION
FUNCTION Delete (dSHfoFrom AS STRING, SHfoToBin AS INTEGER, SHConfirm AS INTEGER) AS LONG
SHfoFrom = dSHfoFrom & CHR$(0)
QSHFileOperation.ClearSHFileOperationStructure
lpFileOp.wFunc = foDelete
lpFileOp.pFrom = VARPTR(SHfoFrom)
lpFileOp.fFlags = QSHFileOperation.DefaultFlags OR (fofAllowUndo * SHfoToBin) OR (fofNoConfirmation * ABS(SHConfirm - 1))
Result = SHFileOperation(lpFileOp)
END FUNCTION
END TYPE
$TYPECHECK OFF
|