ScottInTexas
04-08-2003, 04:03 PM
I want to be able to kill an app after I have opened and used it. I am using the DestroyWindow API but it doesn't work.
I get the window handle from the FindWindow API and the pass it to my Function to kill the app.
Public Function KillApp(ByVal appHndl As Long) As Boolean
Dim lngIsDead As Long
On Local Error GoTo KillApp_Error
If appHndl = 0 Then
Err.Raise Number:=ERROR_NO_APP_HNDL
End If
lngIsDead = DestroyWindow(appHndl)
KillApp = True
LeaveFromHere:
Exit Function
KillApp_Error:
Select Case Err.Number
Case Is = ERROR_NO_APP_HNDL
Msgbox "No application handle was provided. ", vbOKOnly, "No App To Kill"
Case Else
Msgbox "An error occured in KillApp. " & vbCrLf & _
"Err.Number=" & Err.Number & vbCrLf & _
"Err.Description=" & Err.Description, vbCritical + vbOKOnly, "Kill App Error"
End Select
KillApp = False
Resume LeaveFromHere
End Function
This returns 0 which is supposed to mean the API worked.
Please help.
I get the window handle from the FindWindow API and the pass it to my Function to kill the app.
Public Function KillApp(ByVal appHndl As Long) As Boolean
Dim lngIsDead As Long
On Local Error GoTo KillApp_Error
If appHndl = 0 Then
Err.Raise Number:=ERROR_NO_APP_HNDL
End If
lngIsDead = DestroyWindow(appHndl)
KillApp = True
LeaveFromHere:
Exit Function
KillApp_Error:
Select Case Err.Number
Case Is = ERROR_NO_APP_HNDL
Msgbox "No application handle was provided. ", vbOKOnly, "No App To Kill"
Case Else
Msgbox "An error occured in KillApp. " & vbCrLf & _
"Err.Number=" & Err.Number & vbCrLf & _
"Err.Description=" & Err.Description, vbCritical + vbOKOnly, "Kill App Error"
End Select
KillApp = False
Resume LeaveFromHere
End Function
This returns 0 which is supposed to mean the API worked.
Please help.