Determine whether the program is running and whether the program is running

Source: Internet
Author: User

Determine whether the program is running and whether the program is running

In the recent period, you need to write a small function to determine whether the program is running.
After a program is installed, it may be run by multiple users. So how can we determine that the current user has run this program?

The following is how Insus. NET works:
VB. NET WinForm get running program user name http://www.cnblogs.com/insus/p/5194839.html

Then:
WinForm (VB. NET) Get the username of the current login http://www.cnblogs.com/insus/p/5195126.html

From the above method, if the values are the same, the program has been run by the current user.


Source code:

Public Shared Function IsRunning (processName As String) As Boolean Dim btnIsRun As Boolean = False Dim owner As String = GetProcessOwner (App) Dim po As String = owner. substring (owner. lastIndexOf ("\") + 1) Try Dim listProc () As System. diagnostics. process listProc = System. diagnostics. process. getProcessesByName (processName) If listProc. length> 0 AndAlso GetUserName () = po Then btnIsRun = True Else btnIsRun = False End If Catch ex As Exception btnIsRun = False End Try Return btnIsRun End FunctionView Code

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.