检查以查看当前进程是否仅针对当前用户运行

检查以查看当前进程是否仅针对当前用户运行

本文介绍了VB.NET:检查以查看当前进程是否仅针对当前用户运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于vb.net和一般的编程我还是很陌生.

I am pretty new to vb.net and programming in general.

我正在尝试创建一个函数,以查看进程是否仅针对当前用户正在运行.到目前为止,我已经能够检查该进程是否运行良好.但是,如果该过程正在为单独的用户运行,我将得到误报.

I am trying to create a function that looks to see if a process  is running for the current user only. So far I am able to check if the process is running just fine. But, if the process is running for a separate user, I will get a false positive.

这是我到目前为止所拥有的:

Here is what i have so far:

    Dim p() As Process

   Private Sub CheckIfRunning(processname As String)
        'processname = "SLDWORKS"
        p = Process.GetProcessesByName(processname)
        If p.Count > 0 Then
            ' Process is running
            Console.WriteLine("Solidworks Is Running")
            'Else boolstatus = False

            boolstatus = True

        Else
            ' Process is not running
            Console.WriteLine("Solidworks Is Not Running")
            boolstatus = False
        End If
    End Sub

推荐答案

描述了两种方法这里.

There are two methods described here.

WMI更简单-花费的时间不太可能成为问题.您可以使用在线代码转换器转换该代码,也可以仅将其在VB中重写,因为查询过程是唯一重要的位.

WMI is simpler - the time it takes is not likely to be an issue. You could convert that code using an on-line code converter, or just rewrite it in VB as query process is the only important bit.


这篇关于VB.NET:检查以查看当前进程是否仅针对当前用户运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:44