【VB技巧】VB中判断指定名称的进程是否存在

admin 2021年4月3日19:00:46评论27 views字数 1592阅读5分18秒阅读模式

    VB中判断指定名称的进程是否存在,VB中判断指定名称进程是否存在,VB中判断指定进程是否存在,VB中判断名称进程是否存在,VB判断指定进程存在,VB判断指定名称的进程是否存在,VB判断指定的进程是否存在,VB判断指定进程是否存在,VB判断进程是否存在,VB判断进程存在,VB判断进程,VB Ename.name,GetObject("winmgmts:.rootcimv2:win32_process").instances,winmgmts:.rootcimv2:win32_process,GetObject("WinMgmts:"),WMI.InstancesOf("Win32_Process"),CheckApplicationIsRun。

VB中判断指定名称的进程是否存在:

简洁版:
Dim Ename
For Each Ename In GetObject("winmgmts:.rootcimv2:win32_process").instances_ '循环进程
    If LCase(Ename.name) = LCase("CSTRIKE-ONLINE.EXE") Then MsgBox "请先关掉游戏,否则无法开启外挂!", vbInformation, "提示:"
Next

---------------------------------------------------------------------------

啰嗦版:
Function CheckApplicationIsRun(ByVal szExeFileName As String) As Boolean
    On Error GoTo Err
    Dim WMI, Obj, Objs
    CheckApplicationIsRun = False
    Set WMI = GetObject("WinMgmts:")
    Set Objs = WMI.InstancesOf("Win32_Process")
    For Each Obj In Objs
        If InStr(UCase(szExeFileName), UCase(Obj.Description)) 0 Then
            CheckApplicationIsRun = True
            If Not Objs Is Nothing Then Set Objs = Nothing
            If Not WMI Is Nothing Then Set WMI = Nothing
            Exit Function
        End If
    Next
    If Not Objs Is Nothing Then Set Objs = Nothing
    If Not WMI Is Nothing Then Set WMI = Nothing
    Exit Function
Err:
    If Not Objs Is Nothing Then Set Objs = Nothing
    If Not WMI Is Nothing Then Set WMI = Nothing
End Function
Private Sub Command1_Click()
    If CheckApplicationIsRun("notepad.exe") = True Then
        MsgBox "已经运行了记事本程序"
    Else
        MsgBox "记事本程序没有运行"
    End If
End Sub

文章来源于lcx.cc:【VB技巧】VB中判断指定名称的进程是否存在

相关推荐: 只用一条DOS,CMD命令判断,搜索,查找局域网,互联网中存活的主机

站长补充: 哈哈哈,文章发出后,又有人留言给了个更给力的命令: for /l %p in (1,1,254) do @ping 192.168.1.%p -n 1 -w 10 |find /i "TTL" 还可以判断互联网哟,速度刚刚的,Soga …… 上周a…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:00:46
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【VB技巧】VB中判断指定名称的进程是否存在http://cn-sec.com/archives/319573.html

发表评论

匿名网友 填写信息