教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> VB >> 在VB程序中通过回收站删除文件 RSS订阅
在VB程序中通过回收站删除文件
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
在VB程序中通过回收站删除文件
作者:土人
在标准工程中添加一个公共对话框和两个按钮即可尝试本例:

Option Explicit

注释:删除文件的API
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As ToBin) As Long
注释:清空回收站的API
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long

Private Type ToBin
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

Const FO_DELETE = &H3
Const FOF_ALLOWUNDO = &H40
Const SHERB_NORMAL = &H0

注释:将文件移至回收站
Private Sub Command1_Click()
Dim Go As ToBin
Dim strFile As String
With CommonDialog1
.Filter = "(*.bak)|*.bak"
.DialogTitle = "删除文件"
.ShowOpen
strFile = .FileName
End With

With Go
.wFunc = FO_DELETE
.pFrom = strFile
.fFlags = FOF_ALLOWUNDO
End With

SHFileOperation Go
End Sub

注释:清空回收站
Private Sub Command2_Click()
Dim RetVal As Long
RetVal = SHEmptyRecycleBin(0&, vbNullString, SHERB_NORMAL)
End Sub

来源:upschool.cn
作者:
关键字:
发表日期:2006-12-20 19:46:12

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:统计VB程序的运行时间   下一篇:检测磁盘类型的信息


2009-1-10 9:28:48
本文的相类似文章
在学习中进步 在进步中成长 教程中国相随您的成长之路
华腾联合科技股份有限公司版权所有
广告联系:Rosibo@163.com