|
-
Apr 9th, 2001, 11:35 AM
#1
How could I close a program throught the API. I need to find a way of closing explorer running some code and then reloading explorer, without leaving Windows (if you know what I mean).
-
Apr 9th, 2001, 12:00 PM
#2
Frenzied Member
You can close a window using the DestroyWindow API Function.
-
Apr 9th, 2001, 12:45 PM
#3
Thanks. Will I be able to start explorer by using:
shell strWinDir + "\explorer.exe"
even if Explorer is closed? doesn't explorer have to be open to run programs using shell?
-
Apr 9th, 2001, 02:37 PM
#4
Vlatko DestroyWindow will close a window, but it will not end the process. You need to send the WM_QUINT message to do this.
Code:
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
Private Const WM_QUIT = &H12
Private sub Command1_Click()
PostMessage hwnd_of_window, WM_QUIT, 0, 0
End Sub
-
Apr 9th, 2001, 02:43 PM
#5
Thanx but, how do I get the handle for a program?
-
Apr 9th, 2001, 02:53 PM
#6
PowerPoster
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim hWnd As Long
hWnd = FindWindow("NotePad", vbNullString) 'Here, you can supply the class name or the window caption
End Sub
-
Apr 9th, 2001, 03:05 PM
#7
And to get the Classname for a window, you'd use a Spy tool such as Spy++.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|