Results 1 to 5 of 5
  1. #1
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed

    [Tutorial][Function] Doing something if a process is closed or open.

    ProcessIsOpen(String) Function

    Function

    Code:
    Function ProcessIsOpen(ByVal ProcessName As String)
            Dim Process As New Process()
            Dim CacheHolder = ""
            For Each Process In Process.GetProcesses(My.Computer.Name)
                On Error Resume Next
                CacheHolder = CacheHolder + " " + Process.ProcessName + ".exe"
            Next
            If CacheHolder.ToString.Contains(ProcessName) Then
                Return 1
            Else
                Return 0
            End If
        End Function

    Example Of Usage


    Code:
    if ProcessIsOpen("notepad") Then
    Msgbox("Notepad is Running")
    Else
    Msgbox("Notepad is Closed")
    End if
    ^* The Above code will display a message box saying
    "Notepad Is Running" if notepad is open, and if its closed it will say Notepad is Closed*^



    Why can this be useful?


    If you don't want a user using your program with another one then you can use this function to set your program to close; For example per say your program holds values you can have it close if it sees cheat engine open.



    Closing your program, when another one opens.

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If ProcessIsOpen("notepad.exe") Then
    Me.Close()
    End If
    End Sub


    I think that pretty much covers it. if you have any questions feel free to ask, but if you want to flame I would prefer you wouldn't, and I am sure I could of done it a better way, but should I spend time editing to make it look professional, when it works as it is.


    Credits


    Lolland - For Having a account on MPGH
    PixieCorp - For Having a MSN
    NextGen1 - Just because if he wasn't hear it would be wierd.
    BombsAway### - I liked all his tuts when he used to post them
    Coder Never - Coding it HIMSELF with Help of Visual Basic 2008 and Microsoft and Bill Gates
    Last edited by CoderNever; 02-14-2010 at 12:44 AM.

  2. The Following 4 Users Say Thank You to CoderNever For This Useful Post:

    Blubb1337 (02-14-2010),Lolland (02-14-2010),Zoom (02-14-2010),___x][GooD. (12-08-2010)

  3. #2
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Nice tutorial, thanks + rep.

    Will definitely come in useful.

    KEEP UP THE GOOD WORK.

  4. #3
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    i learned this in another way...


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

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  5. #4
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    hmmm good tut.

  6. #5
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Not bad, Decent


     


     


     



    The Most complete application MPGH will ever offer - 68%




Similar Threads

  1. IM DOING SOMETHING WRONG!
    By dane98 in forum Combat Arms Help
    Replies: 19
    Last Post: 03-28-2011, 09:28 AM
  2. Something i tried doing
    By DawgiiStylz in forum Showroom
    Replies: 6
    Last Post: 10-13-2010, 01:19 AM
  3. Am I doing something wrong?
    By adapter in forum WarRock - International Hacks
    Replies: 7
    Last Post: 05-21-2009, 07:59 PM
  4. [Tutorial(C++)]How to call functions within another process
    By radnomguywfq3 in forum Programming Tutorials
    Replies: 4
    Last Post: 07-08-2008, 07:33 PM
  5. Replies: 8
    Last Post: 07-09-2007, 03:15 PM