black dog美少女c78:怎样用VB编程查看系统是否运行了一个叫Mserver的进程?

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 05:21:50

Public Function GetProcessHandle As Long(ByVal sPath As String)'获取被监控进程的进程句柄
sPath = LCase(sPath)
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)'创建一个snapshot对象
pe.dwSize = Len(pe)
bValue = Process32First(hSnapshot, "Mserver")'开始遍历系统进程池
While bValue <> 0
If InStr(LCase(pe.szExeFile), sPath) <> 0 Then'如果找到了,则…
Dim hProcess As Long
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pe.th32ProcessID)
GetProcessHandle = hProcess
CloseHandle hSnapshot
Exit Function
End If
bValue = Process32Next(hSnapshot, pe)
Wend
CloseHandle hSnapshot
GetProcessHandle = 0'否则返回0
End Function