VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 307,222 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,675 people online right now. Registration is fast and FREE... Join Now!




Check if a program is running

 

Check if a program is running

josh.net

3 Feb, 2009 - 06:33 PM
Post #1

New D.I.C Head
*

Joined: 23 Dec, 2008
Posts: 4

I am creating a program that will check if a program is running, by checking its window title (NOT THE FILENAME, ITS WINDOW TITLE) and seeing if it is currently running.
So far I was only able to check if the program was running by its filename

Function:
CODE

    Public Function ProcessesRunning(ByVal ProcessName As String) As Integer
        '
        Try
            Return Process.GetProcessesByName(ProcessName).GetUpperBound(0) + 1
        Catch
            Return 0
        End Try

    End Function


use it in code (in this case, a timer event):
CODE

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If ProcessesRunning("CCleaner") = 1 Then
            ' (one instance)
            'do stuff
        Else
            ' (no instances)
        End If


The code mentioned above only works if you know the filename in this case you would need to use "CCleaner" because thats the filename of ccleaner, but I need to check by its Window Title, which would be "Piriform CCleaner", but if I put that in place of the "CCleaner", it wont work. Any suggestions?

This post has been edited by josh.net: 3 Feb, 2009 - 06:38 PM

User is offlineProfile CardPM
+Quote Post


Posts in this topic

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:43PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month