非常简单的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打包成exe后出错 读文本文件!---在线等 怎样删除一个非空的文件夹? 请问:怎样取出word文档的内容? 征求厦门VB辅导老师,请联系[email protected](在线等待) 大侠们请帮小弟一下,Hook 问题!!!!!!! 如何使用excel的模板来做报表? (2)记录只有5条,而表格行数有20行,怎么让后面15行也照样有横线 在ASP里面为什么记录的PageCount、AbsolutePage、Recordcount有时不可用? 请问如何把参与分变为可用分? 不能改变窗体大小 怎么修改?? 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]