Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Programs 1

Status
Not open for further replies.

visualJay

Programmer
Jun 14, 2001
57
US
How do you close a program like IE and I mean Completely close it like killing the task from taskmanager on a NT or 9x Machine.

I can open a program from a shell comannd can not get one to close.

 
If you start it using CreateObject or New InternetExplorer, then you can use the Close method supplied with the InternetExplorer object.
 
check out this code i got from the internet

module--

Option Explicit

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const WM_CLOSE = &H10
----module over

---class
Option Explicit


Public Function KillApp(ByVal WinAppName As String) As Boolean
Dim winHwnd As Long
Dim RetVal As Long

winHwnd = FindWindow(vbNullString, WinAppName)

Debug.Print winHwnd

If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
KillApp = False
Exit Function
End If
Else
KillApp = False
Exit Function
End If

KillApp = True
End Function

----class over


create a dll and use it in the project or just create the exe and use it.need to pass hte tittle of the application.
test with notepad or calculator application


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top