Results 1 to 2 of 2

Thread: Another Taskmananger question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Another Taskmananger question

    If I have a program that is designed to close all programs of a certain name, is there a way I can prevent it from closing itself if it has that same name. Like for example with my program you can run it as many times as you want. Each copy of the program has code to close all processes that are its name. The thing is that when I do this, sometimes it ends up closing the program that is calling it and then they all don't get closed. Is there a way I can close all of the other programs then close the one thats calling it?

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Another Taskmananger question

    You can try something like comparing the main window handle of the process, see if it is equal to the handle you are working in (I am assuming this code would only work if you are running it from the main application window... not a child window of the application...
    VB Code:
    1. Dim px() As Process = Process.GetProcesses
    2.         For Each proc As Process In px
    3.             If Not proc.MainWindowHandle.ToInt32 = Me.Handle.ToInt32 Then
    4.                 proc.CloseMainWindow()
    5.             Else
    6.                 MessageBox.Show("The app is me!")
    7.             End If
    8.         Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width