Results 1 to 14 of 14

Thread: closing a program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    Unhappy

    I'm totally stumped I want to have a button that closes internet explorer, but I don't have a clue how to get it done.
    Anyone have any ideas?

  2. #2
    Guest
    You could use this program which will list the exe and when you select the exe and you click the button on the list, it will close. Here is the program: App List and Kill

  3. #3
    Guest
    Try this:
    Code:
    Private 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, ByVal lParam As Long) As Long
    
    Const WM_CLOSE = &H10
    Const WM_DESTROY = &H2
    
    Private Sub Command1_Click()
    
        'Find the hWnd of the IE
        hParent = FindWindow("IEFrame", vbNullString)
        'If it's found then close it
        If hParent <> 0 Then
            PostMessage hParent, WM_CLOSE, 0, 0
            PostMessage hParent, WM_DESTROY, 0, 0
        End If
        
    End Sub

  4. #4
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Megatron-How many times have you posted that code, i see it three times a day!!!
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  5. #5
    Guest
    gwdash, Megatron only answers the question, he doesn't go searching for it and tell them that he posted it.
    I don't think he really wants to waste time looking for a post he made several hours ago.
    He does do it sometimes though, but if people did what I did, and searched for the answer of the question before posting the question on the vb-world forums, than the same question wouldn't be asked over and over again.
    But people usually want the answer now, and than they post their question, Megatron or anyone comes along and either searches for it fast or knows it and they reply and both are satisfied, usually, and go on with their lives..only to ask another question a few hours later .
    I think Megatron does a good job, he answers a lot of posts everyday and usually satisfies everyone with their answer.
    Or if someone posts something, Megatron always has something better..hehe .

    Well, I'm just speaking what's on my mind. Hope it gets to you .

  6. #6
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Unfortunately Megatron's standard is not as high as mine, but he'll learn.
    Courgettes.

  7. #7
    Guest
    gwdash: As long as the question is answered, it doesn't make a difference how I get it or how many times a day I answer it. People come to these forums looking for answers and I'll do my best to provide them with it.

  8. #8
    Member
    Join Date
    Sep 2000
    Posts
    48

    Question More question about this

    Hi, sorry to dig up an old post, but this might be the question to my problem.

    Megatron, how did you know the window name of IE is
    "IEFrame"? Doesn't it show whatever webpage it's currently displaying? Or is there a generic name like IEFrame?

    If IEFrame is a generic name, how do I find out the generic name for an application? I have a program that constantly changes the title on the title bar, just like IE.

    Thanks!

  9. #9
    Guest
    Wow, this thread is from months ago!



    Use the GetClassName API function to get the class of a window.

  10. #10
    Member
    Join Date
    Sep 2000
    Posts
    48

    Thumbs up Hey!

    Brilliant! Thanks Matt!


  11. #11
    Guest
    Or you can use the tool called Spy++, which is shipped with Visual Studio.

  12. #12
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Ok, I'm in the process of trying to learn how to use the API. From the above question, I went and used the SPY++ prog, and for IE it told me "Internet Explorer_Server". Why isn't it the same as what Megatron used in his code??? Thanks

  13. #13
    Guest
    That's because IEFrame is the window itself, you are getting the class of the control inside of the window.


    Example:


    Code:
    Dim ieframe As Long, shelldocobjectview As Long, internetexplorerserver As Long
    ieframe = FindWindow("ieframe", vbNullString)
    shelldocobjectview = FindWindowEx(ieframe, 0&, "shell docobject view", vbNullString)
    internetexplorerserver = FindWindowEx(shelldocobjectview, 0&, "internet explorer_server", vbNullString)

  14. #14
    New Member
    Join Date
    Jan 2001
    Posts
    15

    Cool Closing Netscape

    I don't have netscape, but can someone use spy++ to tell me what its handle is? I know for Internet Explorer it is IEFrame, but i need to know the handle foe Netscape.

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