Checking for a process..

Hello--

I am wondering if there is a way to check the current running processes to see if a specific file is running? I am wanting to do this so I can prevent my program from running two copies at once.. Or, is there an easier way to do this without creating a temporary file or (preferably) without modifying the registry? Thanks.

Ian
LVL 1
ianpughAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
To check if your Application is already running, check the value of App.PrevInstance
if you want to know if any application is running, i can post API solution...
0
 
ianpughAuthor Commented:
Thanks! It works great..

Ian
0
 
Erick37Commented:
Check for a previous instance using the App object:

Private Sub Form_Load()
    'This form must be the startup form
    If App.PrevInstance Then End
End Sub

OR:

Sub Main()
    If Not App.PrevInstance Then
        frmMain.Show
    End If
End Sub

Or a more involved approach:

"HOWTO: Prevent Multiple Instances of a 32-bit VB Application"
http://support.microsoft.com/support/kb/articles/Q185/7/30.ASP
0
 
Erick37Commented:
That was quick!
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Faster than my shadow ....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.