Option ExplicitPrivate Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End TypePrivate Declare Function CreateProcessBynum Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long Dim batname As StringPrivate Sub Form_Load() Dim pinfo As PROCESS_INFORMATION 'ƒvƒƒZƒX\‘¢‘Ì Dim res As Long ' Dim sinfo As STARTUPINFO ' Const NORMAL_PRIORITY_CLASS = &H20 ' Const INFINITE = &HFFFF 'ƒ^ƒCƒ€ƒAƒEƒg§ŒÀ‚È‚µFreeFile batname = "c:\a.bat" Open "c:\a.bat" For Append As #1 Print #1, "del c:\a.exe" Close #1 res = CreateProcessBynum(batname, vbNullString, 0, 0, True, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, sinfo, pinfo) 'sinfo.cb = Len(sinfo) 'sinfo.lpReserved = vbNullString 'sinfo.lpDesktop = vbNullString 'sinfo.lpTitle = vbNullString 'sinfo.dwFlags = 0Unload Me End Sub'以上程序的原理是先在c盘下写一个bat文件,在里面写上删除程序的语句,然后创建一个进程,使它运行这个bat文件,然后将主程序退出即可!
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End TypePrivate Declare Function CreateProcessBynum Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
Dim batname As StringPrivate Sub Form_Load()
Dim pinfo As PROCESS_INFORMATION 'ƒvƒƒZƒX\‘¢‘Ì
Dim res As Long '
Dim sinfo As STARTUPINFO '
Const NORMAL_PRIORITY_CLASS = &H20 '
Const INFINITE = &HFFFF 'ƒ^ƒCƒ€ƒAƒEƒg§ŒÀ‚È‚µFreeFile
batname = "c:\a.bat"
Open "c:\a.bat" For Append As #1
Print #1, "del c:\a.exe"
Close #1
res = CreateProcessBynum(batname, vbNullString, 0, 0, True, NORMAL_PRIORITY_CLASS, ByVal 0&, vbNullString, sinfo, pinfo)
'sinfo.cb = Len(sinfo)
'sinfo.lpReserved = vbNullString
'sinfo.lpDesktop = vbNullString
'sinfo.lpTitle = vbNullString
'sinfo.dwFlags = 0Unload Me
End Sub'以上程序的原理是先在c盘下写一个bat文件,在里面写上删除程序的语句,然后创建一个进程,使它运行这个bat文件,然后将主程序退出即可!