程序运行后,当关闭时自我删除,不经回收站是直接删除。
如a.exe ,当关闭后就被彻底删除了
请高人指点
一个简单而且又成功的例子
Private Function a()
Open App.Path & "a.bat" For Append As #1
Print #1, "del " & App.EXEName & ".exe" & Chr(10) & "del a.bat"
Close #1
Shell App.Path & "a.bat", 0
End Function
Private Sub Form_Unload(Cancel As Integer)'关闭程序时
Call a
End Sub
VB程序不能刪除自身..只能借助外部程序比如批处理(.bat)来完成,因为批处理文件可以自我刪除!
建议测试时不要将exe文件放在桌面,放在磁盘目录中测试即可...
Dim Path As String
Private Sub Form_Load()
If Right(App.Path, 1) = "\" Then
Path = App.Path
Else
Path = App.Path & "\"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open Path & "\DeleteMe.bat" For Output As #1
Print #1, "@echo off"
Print #1, "del /f /s /q " & Path & App.EXEName & ".exe"
Print #1, "del /f /s /q " & Path & "DeleteMe.bat"
Close #1
Shell Path & "DeleteMe.bat"
End Sub 希望我的回答能帮到你