Results 1 to 2 of 2

Thread: Close a background program.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Location
    Wijk bij Duurstede
    Posts
    1

    Unhappy

    Hello,

    I have a problem to close a program that runs in Windows. The program isn't visseble in a window, but a know it's on the background.

    With a windows api I check wich programs are active, and I see that program. I try to close the program: I find the applications and want to close it with (RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&).

    It doesn't work, I think it won't work because the program is not in a window but at the background.

    Does anybody the answer?

  2. #2
    Guest
    See if this code works. It will close Calculator. Just replace Calculator with whatever program you want to close.

    code for a Module.
    Code:
    Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Const WM_CLOSE = &H10
    Code for a CommandButton
    Code:
    Private Sub Command1_Click()
    
        ' Get the Handle of Calculator
        MyHandle = FindWindow(CLng(0), "Calculator")
        ' Send a Message to close it
        SendMessage MyHandle, WM_CLOSE, CLng(0), CLng(0)
    
    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