Results 1 to 5 of 5

Thread: Question on closing processes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Question on closing processes

    Hey. So in my program I have code that will automatically check the task manager to see if any programs with a certain name are open. Is there any way I can also make it so that if it finds a program open, it can call a specific method within that program?

    Thanks
    John

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

    Re: Question on closing processes

    Only if there is some built in method of doing it, which I doubt there is. In order to interact with outside applications, you more than likely will need to use API. What are you trying to do?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Re: Question on closing processes

    hmm well I want to close programs, but for some reason when I use the .closeMainWindow() method it doesn't seem to close it -- I'm forced to use .kill(). So I want to call a special method that runs the shutdown commands, then i can kill it...

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

    Re: Question on closing processes

    Well CloseMainWindow() will only work if there is a window associated with the application. Would these be services, by chance?

  5. #5
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: Question on closing processes

    CloseMainWindow, should be equivelant to clicking the close button on a form.
    However you can use API like this:
    VB Code:
    1. 'Top of the form below imports etc
    2. Const WM_CLOSE = &H10
    3. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Object) As Integer
    4. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    5.  
    6. 'In some event like a button click, post the message like this:
    7. PostMessage(FindWindow(vbNullString, exe.MainWindowTitle.ToString()), WM_CLOSE, 0, 0)
    Otherwise you'll need to automate these with virtual keys.
    I can help with that too, if you need.

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