CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Posts
    45

    Close a running program....

    how would i close a prorgam already running? like notepad


  2. #2
    Guest

    Re: Close a running program....

    You can use SendMessage API function with WM_Close parameter. You need to know WindowsClass of the running application, which you can find with Spy++ (VS tool). Or send me your E-Mail address and I'll send you Class to kill Application by its name.
    My e-mail [email protected]
    Vlad


  3. #3
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Close a running program....

    1) Make a command button (command1) and place this code into a formrivate Declare Function FindWindow Lib "user32" Alias _
    "FindWindowA" (byval lpClassName as string, _
    byval lpWindowName as string) as Long
    private Declare Function PostMessage Lib "user32" Alias _
    "PostMessageA" (byval hwnd as Long, byval wMsg as Long, _
    byval wParam as Long, lParam as Any) as Long

    private Sub Command1_Click()

    wHandle = FindWindow(vbNullString, "Notepad")
    target = PostMessage(wHandle, &H10, 0&, 0&)
    If target = 0 then MsgBox "Closed"

    End Sub







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

Featured