另外一种检测SOFTICE的方法,保证用的人很少 ^_^ (1千字)
Public Sub DetectICE(xVersion As String)On Error Resume Next
Dim x As Long
Randomize
xF = CLng(Rnd * 29999)
x = Shell("cmd.exe /c net stop " & xVersion & " > \nul 2>c:\tmp" & Trim(CStr(xF)) & ".txt", vbHide)
xTime = Timer
Do
DoEvents
If Dir$("c:\tmp" & Trim(CStr(xF)) & ".txt") <> "" Or Timer > (xTime + 3) Then
If Timer > (xTime + 3) Then
Exit Do
ElseIf FileLen("c:\tmp" & Trim(CStr(xF)) & ".txt") > 30 Then
Exit Do
End If
End If
Loop
If FileLen("c:\tmp" & Trim(CStr(xF)) & ".txt") > 30 Then
Dim xFile As String
xFile = String(FileLen("c:\tmp" & Trim(CStr(xF)) & ".txt"), 0)
Open "c:\tmp" & Trim(CStr(xF)) & ".txt" For Binary As #1
Get #1, 1, xFile
Close #1
If LCase(xVersion) = "ntice" Then
xSoft = "SoftICE-NT"
Else
xSoft = "SoftICE-9x"
End If
If InStr(1, xFile, "specified service does not exist") > 0 Then
MsgBox xSoft & " does not exist on this machine."
ElseIf InStr(1, xFile, "requested pause or stop is not valid") > 0 Then
MsgBox xSoft & " is installed AND RUNNING"
ElseIf InStr(1, xFile, "service is not started") > 0 Then
MsgBox xSoft & " is installed but not running at the moment."
Else
MsgBox "Error - unable to determine. Results:" & vbCrLf & xFile
End If
Else
MsgBox "Error - couldn't determine."
End If
Kill "c:\tmp" & Trim(CStr(xF)) & ".txt"
End Sub
用法:
On Error Resume Next ' 呵呵,我怕她出错。。。
Call DetectICE("ntice")
Call DetectICE("sice")
