窗体上添加一个 text 一个按钮 只需在text中输入进程名单击一下按钮 就可以
只需要三个api
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String 1024
End Type
Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Dim pid As Long
Dim pname As String
Dim a As String
Private Sub Command1_Click()
a = Trim(LCase(Text1))
Dim my As PROCESSENTRY32
Dim l As Long
Dim l1 As Long
Dim flag As Boolean
Dim mName As String
Dim i As Integer
l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If l Then
mydwSize = 1060
End If
If (Process32First(l, my)) Then '遍历第一个进程
Do
i = InStr(1, myszExeFile, Chr(0)) '返回chr(0)在各个进程中出现的位置
mName = LCase(Left(myszExeFile, i - 1)) '返回小写的(返回i-1的前n个字符,即正确的名称)
If mName = a Then
pid = myth32ProcessID
Text1 = Text1 & "的pid是 " & "---" & pid
End If
Loop Until (Process32Next(l, my) < 1)
End If
End Sub
Private Sub getSoftwareList()
Dim rk As MicrosoftWin32RegistryKey = MicrosoftWin32RegistryLocalMachineOpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
Dim names As String() = rkGetSubKeyNames
For Each s As String In names
textbox1Text&=s+vbCtrf;
Next
End Sub
ProcessGetCurrentProcessProcessName
'--------------------
百度VB2010(VBNET)吧建设发展中,需要你的支持和帮助!!!
快加入我们吧!发表你的疑问,经验,程序,分享
让我们共同进步!
VB可以使用FileListBox 控件来获取指定文件夹内的所有文件名。
FileListBox 控件,在运行时,在 Path 属性指定的目录中,FileListBox 控件将文件定位并列举出来。该控件用来显示所选择文件类型的文件列表。例如,可以在应用程序中创建对话框,通过它选择一个文件或者一组文件。
以下是组合使用DriveListBox 、控件DirListBox 控件和FileListBox 控件来获取硬盘下任何一个文件夹内的文件名。
Private Sub Dir1_Change()
File1Path = Dir1Path
End Sub
Private Sub Drive1_Change()
Dir1Path = Drive1Drive
End Sub
Private Sub File1_Click()
Dim i As Long
DebugPrint "目录夹内存在" & File1ListCount & "个文件。"
End Sub
以上就是关于VB里如何通过PID得到进程名称全部的内容,包括:VB里如何通过PID得到进程名称、VB如何读取系统已安装软件并读取其图标和名称、VB.NET 如何获取本身的进程名等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)