你想要的应该就是这个吧
榆社网站建设公司成都创新互联,榆社网站设计制作,有大型网站制作公司丰富经验。已为榆社上1000+提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的榆社做网站的公司定做!
'获取进程id
Dim p As Integer = Shell(TextBox1.Text)
'获取进程id对应的句柄
Dim h As IntPtr = System.Diagnostics.Process.GetProcessById(p).Handle
'显示进程id和对应的句柄
Debug.Print(p)
Debug.Print(h.ToString)
关于进程的问题你问了多次吧,为何不多看看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取进程。
正好我写个一个函数封装在DLL里了,代码是这样的:
''' 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
使用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
''' 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
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款