非常简单的api函数问题~~~ 用FileSystemObject不是挺好?直接就可以删。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我不想用fso这样做没意义,我想学api,请各位高手指教. 这个绝对不能呼叫 VB 所提供的 Kill 叙述, Kill 叙述只会将档案从磁碟中删除, 若要将档案丢到资源回收筒, 必须呼叫 SHFileOperation API 函数, 假设我们想将 c:\test.txt 丢到资源回收筒, 则呼叫的叙述如下:Dim SHFileOp As SHFILEOPSTRUCTSHFileOp.wFunc = FO_DELETESHFileOp.pFrom = "c:\test.txt" + Chr(0)SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)在以上叙述中有几件值得注意的事情:FOF_ALLOWUNDO 表示被删除的档案将来可以还原, 此一设定值是绝对必要的。 FOF_NOCONFIRMATION 表示不显示交谈窗询问使用者「是否将档案丢到资源回收筒」, 若要询问使用者, 则应取消此一设定值。 请注意 "c:\test.txt" 之後必须加上 Chr(0)。 利用以上方法也可以一次删除多个档案, 此时只要将多个档案名称串在一起, 并且以 Chr(0) 分隔即可, 假设我们想删除 c:\test1.txt、c:\test2.txt、及 c:\test3.txt 等叁个档案, 则程式如下:Dim SHFileOp As SHFILEOPSTRUCTDim Files As StringFiles = "c:\test1.txt" + Chr(0) + "c:\test2.txt" + Chr(0) + "c:\test3.txt" + Chr(0)SHFileOp.wFunc = FO_DELETESHFileOp.pFrom = FilesSHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)How to empty the Recycle Bin within a VB-Application using the APIPrivate Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As LongPrivate Const SHERB_NORMAL = &H0 'Normal executionPrivate Const SHERB_NOCONFIRMATION = &H1 'execute without confirmationPrivate Const SHERB_NOPROGRESSUI = &H2 'execute without progress windowPrivate Const SHERB_NOSOUND = &H4 'execute without soundPrivate Const SHERB_NOALL = (SHERB_NOCONFIRMATION And SHERB_NOPROGRESSUI And SHERB_NOSOUND)Dim RetVal As LongPrivate Sub EmpRecBin() RetVal = SHEmptyRecycleBin(0&, vbNullString, SHERB_NORMAL)End Sub 如果要详细信息我有一个例子[email protected] 简单的VB问题 XP不安装打印机,如何添加自定义页形(Form) 这数据操做出现阶Object variable or With block variable not set,请各位大虾指点一下 请问是什么原因造成这样的错误 我的vb程序怎么编辑不了啊? 请问如何调用 *.ini 文件连接数据库(急) 关于VBA与Excel应用一问!高手请指教! Adodb RecordSet的Delete方法出错了 VB访问SQL Server中字段的问题,急。 今天某公司棉试,人家不要VB 不能改变窗体大小 怎么修改?? IIS组件与ASP组件的二此开发问题(*****大**甩**分*****)
Dim SHFileOp As SHFILEOPSTRUCT
SHFileOp.wFunc = FO_DELETESHFileOp.pFrom = "c:\test.txt" + Chr(0)SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)
在以上叙述中有几件值得注意的事情:
FOF_ALLOWUNDO 表示被删除的档案将来可以还原, 此一设定值是绝对必要的。
FOF_NOCONFIRMATION 表示不显示交谈窗询问使用者「是否将档案丢到资源回收筒」, 若要询问使用者, 则应取消此一设定值。
请注意 "c:\test.txt" 之後必须加上 Chr(0)。
利用以上方法也可以一次删除多个档案, 此时只要将多个档案名称串在一起, 并且以 Chr(0) 分隔即可, 假设我们想删除 c:\test1.txt、c:\test2.txt、及 c:\test3.txt 等叁个档案, 则程式如下:
Dim SHFileOp As SHFILEOPSTRUCT
Dim Files As String
Files = "c:\test1.txt" + Chr(0) + "c:\test2.txt" + Chr(0) + "c:\test3.txt" + Chr(0)SHFileOp.wFunc = FO_DELETESHFileOp.pFrom = FilesSHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)How to empty the Recycle Bin within a VB-Application using the API
Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As LongPrivate Const SHERB_NORMAL = &H0 'Normal executionPrivate Const SHERB_NOCONFIRMATION = &H1 'execute without confirmationPrivate Const SHERB_NOPROGRESSUI = &H2 'execute without progress windowPrivate Const SHERB_NOSOUND = &H4 'execute without soundPrivate Const SHERB_NOALL = (SHERB_NOCONFIRMATION And SHERB_NOPROGRESSUI And SHERB_NOSOUND)
Dim RetVal As LongPrivate Sub EmpRecBin()
RetVal = SHEmptyRecycleBin(0&, vbNullString, SHERB_NORMAL)
End Sub 如果要详细信息我有一个例子
[email protected]