189 8069 5689

vb.net进程pid VBNet

vb.net怎么确定一个pid是否存在?

正好我写个一个函数封装在DLL里了,代码是这样的:

高淳网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联成立与2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

''' summary

''' 检查进程是否运行

''' /summary

''' param name="ProcessName"要检查的进程名/param

''' returns/returns

''' remarks/remarks

Public Function CheckProcessByName(ByVal ProcessName As String) As Boolean

Dim MgmtClass As New ManagementClass("Win32_Process")

Dim rtnVal As Boolean = False

Dim mo As New ManagementObject()

For Each mo In MgmtClass.GetInstances()

If mo("Name").ToString().ToLower() = ProcessName.ToLower() Then

rtnVal = True

End If

Next

Return rtnVal

End Function

知道PID的话:

''' summary

''' 返回所有窗口句柄

''' /summary

''' returns/returns

''' remarks/remarks

Public Function ListAllProcessesHandle() As String

Dim sb As New StringBuilder()

Dim p As New Process()

For Each p In Process.GetProcesses(".")

Try

If p.MainWindowTitle.Length 0 Then

sb.Append("句柄:" + p.MainWindowHandle.ToString() + Environment.NewLine)

End If

Catch

End Try

Next

Return sb.ToString()

End Function

窗口隐藏进程总有吧,函数调用的参数是进程名,不是窗口名。

函数是自己写的没有调用API

vb.net 如何根据进程名字来取得进程的pid?

''' summary

''' 返回某进程PID

''' /summary

''' param name="ProcessName"进程名(不带后缀)/param

''' returns/returns

''' remarks/remarks

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

求大神指点 vb.net 怎么通过进程pid取所加载的所有模块 路径

关于进程的问题你问了多次吧,为何不多看看Process

Dim p As Process() = Process.GetProcessesByName("qq")

If p.Count = 1 Then

Dim p1 As Process = p(0)

Dim m = p1.Modules '进程的所有模块。

End If

Dim p As Process = Process.GetProcessById(Pid)‘通过pid取进程。

vb.net如何获取当前进程的cpu和内存使用率?

使用wmi

类“Win32_Processor”中LoadPercentage属性为当前的cpu使用率

示例代码: Private Sub Timer1_Timer()

Dim WMI服务 As Object

Dim 对象 As Object

Dim 子对象 As Object

Dim 电脑名 As String

Dim 刷新 As Long

刷新 = 0

电脑名 = "." '表示本地计算机

Set WMI服务 = GetObject("winmgmts://" 电脑名 "/root/cimv2")

Set 对象 = WMI服务.InstancesOf("Win32_Processor")

Me.CurrentX = 0

Me.CurrentY = 0

For Each 子对象 In 对象

If 刷新 = 0 Then

刷新 = 1

Me.Cls

End If

Me.Print 子对象.Name "[" 子对象.CurrentClockSpeed "Hz] 使用率:" _

子对象.LoadPercentage "%"

Next

End Sub


分享标题:vb.net进程pid VBNet
浏览路径:http://cdxtjz.cn/article/dodjdse.html

其他资讯