Code : Tout sélectionner
Procedure MoveFileToRecycleBin(DeletedFile.s)
Protected lpFileOp.SHFILEOPSTRUCT
If FileSize(DeletedFile) <> -1
If Right(DeletedFile, 1) = "\"
DeletedFile = Left(DeletedFile, Len(DeletedFile) - 1)
EndIf
Mem = AllocateMemory(0, Len(DeletedFile)+2, 0)
If Mem
lpFileOp\hwnd = 0
lpFileOp\pTo = 0
lpFileOp\wFunc = #FO_DELETE
lpFileOp\pFrom = Mem
lpFileOp\fFlags = #FOF_ALLOWUNDO | #FOF_NOCONFIRMATION
CopyMemoryString(DeletedFile, @Mem)
CopyMemoryString(Chr(0))
CopyMemoryString(Chr(0))
SHFileOperation_(@lpFileOp)
FreeMemory(0)
EndIf
EndIf
EndProcedure
MoveFileToRecycleBin("C:\Nouveau Document texte.txt")