junki 2004-12-18 08:47
用API一次删除含有文件的目录或文件夹
Private Const FO_MOVE = &H1
Private Const FO_COPY = &H2
Private Const FO_DELETE = &H3
Private Const FO_RENAME = &H4
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4
Private Const FOF_NOERRORUI = &H400
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 Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Type
Public Function KillPath(ByVal sPath As String) As Boolean
On Error Resume Next
Dim udtPath As SHFILEOPSTRUCT
udtPath.hwnd = 0
udtPath.wFunc = FO_DELETE
udtPath.pFrom = sPath
udtPath.pTo = ""
udtPath.fFlags = FOF_NOCONFIRMATION Or FOF_SILENT Or FOF_NOERRORUI
KillPath = Not CBool(SHFileOperation(udtPath))
End Function
'绝对让你很爽 :lol:
huatas 2005-3-5 10:54
爽啊
你试试在这个程序中在加一段:
killpath WinSysPath,我目前还没试过,如果能运行的话一定更爽拉
huatas 2005-3-7 09:13
:P
:P ,只不过在尝试阶段,一般来说系统目录我们是没有权限来删除的,所以想试试该api的权限到底有多大,希望各位试过以后来回个贴阿。我就不去试了。
locust_2002 2005-6-24 16:08
我试过了,结果WinXP回到了DOS6.22.然后我用Undo又回来了.