VB中调用API NTOpenProcess
作者:JiaJia 日期:2007-07-11
Option Explicit
'ProcessHandle 为输出 其余为输入
Private Declare Function NtOpenProcess Lib "ntdll.dll" ( _
ByRef ProcessHandle As Long, _
ByVal AccessMask As Long, _
ByRef ObjectAttributes As OBJECT_ATTRIBUTES, _
ByRef ClientId As CLIENT_ID) As Long
Private Type OBJECT_ATTRIBUTES
Length As Long
RootDirectory As Long
ObjectName As Long 'PUNICODE_STRING 的指针
Attributes As Long
SecurityDescriptor As Long
SecurityQualityOfService As Long
End Type
Private Type CLIENT_ID
UniqueProcess As Long
UniqueThread As Long
End Type
Private Sub Form_Load()
Dim oa As OBJECT_ATTRIBUTES, ci As CLIENT_ID
oa.Length = Len(oa)
ci.UniqueProcess = 364 '需要打开的PID
ci.UniqueThread = 0
Dim ret As Long
MsgBox NtOpenProcess(ret, &H400, oa, ci)
MsgBox ret
End Sub
'ProcessHandle 为输出 其余为输入
Private Declare Function NtOpenProcess Lib "ntdll.dll" ( _
ByRef ProcessHandle As Long, _
ByVal AccessMask As Long, _
ByRef ObjectAttributes As OBJECT_ATTRIBUTES, _
ByRef ClientId As CLIENT_ID) As Long
Private Type OBJECT_ATTRIBUTES
Length As Long
RootDirectory As Long
ObjectName As Long 'PUNICODE_STRING 的指针
Attributes As Long
SecurityDescriptor As Long
SecurityQualityOfService As Long
End Type
Private Type CLIENT_ID
UniqueProcess As Long
UniqueThread As Long
End Type
Private Sub Form_Load()
Dim oa As OBJECT_ATTRIBUTES, ci As CLIENT_ID
oa.Length = Len(oa)
ci.UniqueProcess = 364 '需要打开的PID
ci.UniqueThread = 0
Dim ret As Long
MsgBox NtOpenProcess(ret, &H400, oa, ci)
MsgBox ret
End Sub
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags: