对付RtlSetProcessIsCritical
这不是vb6代码,看不懂就算了
Private Declare Function NtQueryInformationProcess Lib "ntdll" (ProcessHandle As IntPtr, ProcessInformationClass As Integer, ByRef ProcessInformation As Integer, lProcessInformationLength As Integer, ByRef lReturnLength As Integer) As Integer
Private Declare Function NtSetInformationProcess Lib "ntdll" (ProcessHandle As IntPtr, ProcessInformationClass As Integer, ByRef ProcessInformation As Integer, lProcessInformationLength As Integer) As Integer
Const ProcessBreakOnTermination = 29
Public Sub SetProcessIsNotCritical(hProcess As Integer)
If hProcess = 0 Then Throw New ArgumentException( "句柄是0")
Dim Status As Integer
Dim Enable As Integer
Status = NtQueryInformationProcess(hProcess,
ProcessBreakOnTermination,
Enable,
4,
0)
If Status <> 0 Then
Throw New componentmodel.win32Exception(Status)
End If
If Enable = 0 Then Return
Enable = 0 ‘关键。去除关键进程属性,如果是1就打开这个属性。
Status = NtSetInformationProcess(hProcess,
ProcessBreakOnTermination,
Enable,
4)
If Status <> 0 Then
Throw New componentmodel.win32Exception("操作失败,错误代码:" & Status)
End If
End Sub