Public Type SHFILEOPSTRUCT hwnd As Long wFunc As Long pFrom As String pTo As String fFlags As Integer fAnyOperationsAborted As Long hNameMappings As Long lpszProgressTitle As Long End Type
Public Declare Function SHFileOperation Lib "shell32.dll" Alias _ "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Const FO_DELETE = &H3 Public Const FOF_ALLOWUNDO = &H40 ′可以还原 Public Const FOF_NOCONFIRMATION = &H10 ′不出现确认对话框 Public Const FOF_SILENT = &H4
′在程序中之使用方法如下: ′以下之例子会出现确认对话框,文件也会移到资源回收站。 Private Sub Command1_Click() Dim SHop As SHFILEOPSTRUCT Dim strFile As String ′要删除的文件(含全路径) strFile = "c:\test.txt"
With SHop .wFunc = FO_DELETE .pFrom = strFile .fFlags = FOF_ALLOWUNDO End With