vb如何使程序得到保護(hù)
就是使vb程序無法被普通的任務(wù)管理器結(jié)束任務(wù)和taskkill殺死,。雙程序互相保護(hù)也行,,有辦法嗎,?
,。
你這個要hook。復(fù)雜,。
你的防taskkill要hook鉤子,。復(fù)雜,。
互相保護(hù)簡單。代碼:
'查找是否運(yùn)行:
Public Function CheckExeIsRun(exeName) As Boolean
On Error GoTo Err
Dim WMI
Dim Obj
Dim Objs
CheckExeIsRun = False
Set WMI = GetObject("WinMgmts:")
Set Objs = ***.instancesof("Win32_Process")
For Each Obj In Objs
If (InStr(UCase(exeName), UCase(***.description)) <> 0) Then
CheckExeIsRun = True
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
End If
Next
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
Err:
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
End Function
'創(chuàng)建timer1
private sub timer1_timer
if checkexeisrun("工程名" & ".exe") then
else
shell"文件路徑"
end if
'再創(chuàng)建一個文件,,把對象設(shè)置為雙方,,一個退出,就用另一個重啟,。
'采納謝謝,!