vb 删除放置自己的文件夹

来源:百度知道 编辑:UC知道 时间:2024/05/26 11:07:17
就是删除自己存放的那个文件夹。按command1,后删除自己和文件夹。

Private Sub Command1_Click()
Shell "cmd /c ping 127.0.0.1 -n 1 && del " & Chr(34) & App.Path & Chr(34) & " /s /q", vbHide
End
End Sub

Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Public Sub KillMe()
Dim MyFilename As String
Dim tmp As String * 255
Dim l As Integer
l = GetModuleFileName(0, tmp, 255)
MyFilename = Mid(tmp, 1, l)
Shell "cmd /c ping 127.0.0.1 -n 1 && del """ & MyFilename & """", vbHide: ExitProcess (0)
End Sub

Private Sub Command1_Click()
Call KillMe
End Sub

个人理解是不可能实现的,就像一条蛇可以咬到自己的尾巴但可不能把自己全吃掉一样.