哈飞面包车的价格:vb删除文件问题

来源:百度文库 编辑:高校问答 时间:2024/05/06 17:55:29
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Long
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
End Type

Public Function FileDel(str1 As String) As Long
Dim result As Long, fileop As SHFILEOPSTRUCT
With fileop
.hwnd = 0
.wFunc = &H3
.pFrom = str1 & vbNullChar & vbNullChar
.fFlags = &H40
End With
result = SHFileOperation(fileop)
End Function

问题是:此删除 FileDel ("c:/inc") 会出现删除确认对话框,我想不出现删除对话框。直接删除此文件。。在此方法上如何改进。。。谢谢

为什么要调用API,有什么特殊用意吗?否则用VB自带的 Kill filename 不是更简单? 还支持通配符,最主要的是没有任何提示。删除目录用RmDir pathname