IVY DOM


 

人生就像一副复杂拼图
每个人总有属於自己的记忆碎片
优质美国空间-老薛主机|IVY DOM|Flowline|

联系我

RSS




十月 02, 2011

[开源]VB.NET 寻找进程_判断进程是否存在

Public Class Form1
Structure s5yh5sgrty
Public dwSize As Integer
Public cntUsage As Integer
Public Extension As Integer
Public th32DefaultHeapID As Integer
Public syhhbr As Integer ‘srgyvr
Public srgyvr As Integer
Public cntThreads As Integer
Public th32ParentProcessID As Integer
Public pcPriClassBase As Integer
Public dwFlags As Integer
Public name() As Byte
End Structure
Private Declare Function SubClass1 Lib “CreateToolhelp32Snapshot” (ByVal creatphoto As Integer,
Optional ByVal falg As Integer = 0,
Optional ByVal id As Integer = 0) As Integer
‘———————————————–声明API——————————————————
Private Declare Function SubClass2 Lib “Process32Next” (ByVal nexta As Integer,
Optional ByVal h As Integer = 0,
Optional ByVal p As s5yh5sgrty = Nothing) As Integer
‘—————————————————-声明API————————————————-
Private Declare Function SubClass3 Lib “CloseHandle” (ByVal CloseHandle As Integer,
Optional ByVal jubing As Integer = 0) As Integer
‘—————————————————-声明API————————————————-
Private Declare Function SubClass4 Lib “Process32First” (ByVal Process32First As Integer,
Optional ByVal h As Integer = 0,
Optional ByVal p As s5yh5sgrty = Nothing) As Integer
‘———————————————————声明API——————————————–
Function task(ByVal nname As String) As Boolean
Dim news As s5yh5sgrty, 进程快照 As Integer, 进程句柄 As Integer
进程快照 = SubClass1(15, 0)
If (进程快照 = 0) Then
Return (False)
End If
news.dwSize = 1024
进程句柄 = SubClass4(进程快照, Val(news))
If (进程句柄 <> 0) Then
ElseIf news.srgyvr <> 0 Then
ElseIf nname = Str(news.name) Then
SubClass3(进程快照)
Return (True)
进程句柄 = SubClass2(进程快照, Val(news))
End If
SubClass3(进程快照)
Return (False)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If task(“QQ.exe”) = True Then ‘以QQ作为例子
MessageBox.Show(“true”)
ElseIf task(“QQ.exe”) = False Then
MessageBox.Show(“false”)
End If
End Sub
End Class

相关文章

返回
  1. It’s really great that peolpe are sharing this information.

  1. 暂无 Trackback

You must be logged in to post a comment.