Vb2008 如何获取进程PID 10

PublicFunctionFindPID(ByValstrGameNameAsString)AsBooleanDimpe32AsPROCESSENTRY32DimhSn... Public Function FindPID(ByVal strGameNameAs String) As Boolean
Dim pe32 As PROCESSENTRY32
Dim hSnapshot As Integer
Dim bProcFound As Boolean
Dim bFoundGame As Boolean

hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)
pe32.dwSize = Len(pe32)

bProcFound = Process32First(hSnapshot,pe32)
Do While bProcFound
If Right(LCase(Left(pe32.szExeFile,
InStr(1, pe32.szExeFile, Chr(0)) - 1)), Len(strGameName)) = LCase(strGameName)
Then
dwProcId = pe32.th32ProcessID
bFoundGame = True
End If
bProcFound = Process32Next(hSnapshot,pe32)
Loop
CloseHandle(hSnapshot)
dwHandle = OpenProcess(&H1F0FFF,False, dwProcId)
FindGame = bFoundGame
End Function
之前用这个获取程序的PID,可是变成了2008就好像不行
有想过用Process.GetProcessesByName不过不太会用,因为出来的
好像不是我所想要的值(dwProcId),如果有人可以用这个得出PID的数值出来也可以
展开
 我来答
peter987662
2012-12-04 · TA获得超过1330个赞
知道小有建树答主
回答量:1117
采纳率:0%
帮助的人:1194万
展开全部
Public Function ProcessPidOnly(ByVal ProcessName As String) As String
Dim myProcess As Process() = Process.GetProcessesByName(ProcessName)
Dim pid As String = ""
If myProcess.Length - 1 = 0 Then
pid = myProcess(0).Id
Else
For i As Short = 0 To myProcess.Length - 1
pid = pid & myProcess(i).Id & ";"
Next
End If
Return pid
End Function
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式