作者:绿色风
分类:
时间:2022-08-17
浏览:124
楼主 xmyjk |
Q:如何将文件删除至回收站,并清空回收站。
A:API操作之。- Option Explicit
- Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As ToBin) As Long
- 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 删除()
- Dim Go As ToBin
- Dim strFile As String
- strFile = ThisWorkbook.Path & "\1.TXT"
- With Go
- .wFunc = FO_DELETE
- .pFrom = strFile
- .fFlags = FOF_ALLOWUNDO
- End With
- SHFileOperation Go
- End Sub
- Private Sub 清空回收站()
- Dim RetVal As Long
- RetVal = SHEmptyRecycleBin(0&, vbNullString, SHERB_NORMAL)
- End Sub
删除文件.zip |
2楼 yjzstar |
|
3楼 水星钓鱼 |
学习 |
4楼 我是小马儿 |
感觉用kill 方便且简单一点呢。 |
免责声明
有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素,
经与ExcelTip.Net站长Apolloh商议并征得其同意,
现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示,
供有需要的人士查询使用,也慰缅曾经的论坛时代。
所示各个帖子的原作者如对版权有异议,
可与本人沟通提出,或于本站点留言,我们会尽快处理。
在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一