正文

清空垃圾箱的代码2012-05-02 20:05:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/53447.html

分享到:

http://www.developerfusion.com/code/5673/how-to-empty-a-recycle-bin/

貌似能够清空回收站,清空时不会提示用户确认,而且没有提示音和进度条。

Usage: 
Dim Action As New ShellActions 
Action.EmptyRecycleBin() 

Public Class ShellActions 

Shared Function _ 
SHEmptyRecycleBin(ByVal hWnd As Integer, ByVal pszRootPath As String, _ 
ByVal dwFlags As Integer) As Integer 
End Function 

Sub New() 
EmptyRecycleBin() 
End Sub 

Sub EmptyRecycleBin(Optional ByVal rootPath As String = "", _ 
Optional ByVal noConfirmation As Boolean = True, Optional ByVal NoProgress _ 
As Boolean = True, Optional ByVal NoSound As Boolean = True) 

Const SHERB_NOCONFIRMATION = &H1 
Const SHERB_NOPROGRESSUI = &H2 
Const SHERB_NOSOUND = &H4 

If rootPath.Length > 0 AndAlso rootPath.Substring(1, 2) <> ":\" Then 
rootPath = rootPath.Substring(0, 1) & ":\" 
End If 

Dim flags As Integer = (noConfirmation And SHERB_NOCONFIRMATION) Or _ 
(NoProgress And SHERB_NOPROGRESSUI) Or (NoSound And SHERB_NOSOUND) 
SHEmptyRecycleBin(0, rootPath, flags) 

End Sub

阅读(1410) | 评论(3)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册