[求助] VBA清空回收站代码怎么不让出提示?
发布网友
发布时间:2022-05-24 18:26
我来回答
共2个回答
热心网友
时间:2023-10-25 02:48
提示是操作系统给出来的,估计不能受VBA程序的控制把,
也许你可以再模拟点击的动作
如
appactivate (跳出的提示页面的 标题 )
sendkeys "{enter}"
热心网友
时间:2023-10-25 02:48
把你的代码修改如下:
Private Function EmptyBin(Silent As Boolean, Optional hwnd As Long, Optional Drive As String) As Long
Dim rc As Long
Dim dwFlags As Long
Const SHERB_NOCONFIRMATION = 1
Const SHERB_NOPROGRESSUI = 1
Const SHERB_NOSOUND = 1
If IsNumeric(hwnd) = False Then hwnd = 0
dwFlags = SHERB_NOCONFIRMATION + SHERB_NOSOUND
If Silent Then
dwFlags = dwFlags + SHERB_NOPROGRESSUI
End If
rc = SHEmptyRecycleBin(hwnd, ByVal Drive, dwFlags)
End Function
Private Sub Command1_Click()
EmptyBin (3)
End Sub