新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Const SHERB_NOCONFIRMATION = &H1
Private Const SHERB_NOPROGRESSUI = &H2
Private Const SHERB_NOSOUND = &H4
Private Sub Command1_Click()
Dim result As Long
result = SHEmptyRecycleBin(0, "", SHERB_NOCONFIRMATION Or SHERB_NOPROGRESSUI Or SHERB_NOSOUND)
If result = 0 Then
MsgBox "已经清空了回收站!"
End If
End Sub
可以参考《VB6 利用API把文件放到回收站》。