【求助】vb2008调用Process32First错误
Private Declare Function CreateToolhelp32Snapshot Lib "KERNEL32.DLL" Alias "CreateToolhelp32Snapshot" (ByVal dwFlags As Integer, ByRef th32ProcessID As Integer) As IntegerPrivate Declare Function Process32First Lib "KERNEL32.DLL" Alias "Process32First" (ByRef hSnapshot As Integer, ByRef lppe As LPPROCESSENTRY32) As Integer
Private Declare Function Process32Next Lib "KERNEL32.DLL" Alias "Process32Next" (ByRef hSnapshot As Integer, ByRef lppe As LPPROCESSENTRY32) As Integer
Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByRef hObject As Long) As Integer
Private Structure LPPROCESSENTRY32
Dim dwSize As Integer
Dim cntUsage As Integer
Dim th32ProcessID As Integer
Dim th32DefaultHeapID As Integer
Dim th32ModuleID As Integer
Dim cntThreads As Integer
Dim th32ParentProcessID As Integer
Dim pcPriClassBase As Integer
Dim dwFlags As Integer
Dim szExeFile As String
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hSnapshot As Integer
Dim LPPROCESSENTRY32 As LPPROCESSENTRY32
hSnapshot = CreateToolhelp32Snapshot(2, 0)
Debug.Print(hSnapshot)
If hSnapshot <> -1 Then
LPPROCESSENTRY32.szExeFile = ""
LPPROCESSENTRY32.dwSize = 296
If Process32First(hSnapshot, LPPROCESSENTRY32) Then '这里错误:尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
Do
If LPPROCESSENTRY32.szExeFile = "QQ.exe" Then
MsgBox("找到了")
Exit Sub
End If
Loop Until Process32Next(hSnapshot, LPPROCESSENTRY32)
End If
CloseHandle(hSnapshot)
End If
End Sub
API声明里面我改Byref和Byval都没用,都报错,我系统是WIN7旗舰版。求高手帮忙看看 谢谢了 --------------------编程问答-------------------- 怎么都没有人帮忙啊
补充:.NET技术 , VB.NET