VB: InternetExplorer beenden

Hallo zusammen,
eine externe (nicht zu beeinflussende) Anwendung startet den Internet-Explorer.

Kann ich dies (vorher) irgendwie verhindern, bzw. wie kann ich diesen wieder Beenden (es ist nur dieser geöffnet).

Ich will die IEXPLORE.EXE übrigens nicht umbenennen - kann ich die Aufruf „abfangen“ (und statt dessen vielleicht sogar etwas anderes machen)?

Hallo zusammen,
eine externe (nicht zu beeinflussende) Anwendung startet den
Internet-Explorer.

Du mußt die API-Funktion „FindWindow“ benutzen…

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, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW\_SHOWNORMAL = 1
Const WM\_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass\_desked\_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form\_Load()
 'KPD-Team 1998
 'URL: http://www.allapi.net/
 'E-Mail: [email protected]
 Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
 'Ask for a Window title
 Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
 'Search the window
 WinWnd = FindWindow(vbNullString, Ret)
 If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
 'Show the window
 ShowWindow WinWnd, SW\_SHOWNORMAL
 'Create a buffer
 lpClassName = Space(256)
 'retrieve the class name
 RetVal = GetClassName(WinWnd, lpClassName, 256)
 'Show the classname
 MsgBox "Classname: " + Left$(lpClassName, RetVal)
 'Post a message to the window to close itself
 PostMessage WinWnd, WM\_CLOSE, 0&, 0&
End Sub

Gruß Matthias

DO-LOOP nimmt volle CPU-Last - Hilfe!
danke - und wie verhindere ich, dass meine VB-Programm die volle CPU-Leistung nimmt, während ich folgendes mache…


Ret = „Microsoft Internet Explorer“
DO WHILE WinWnd=0
WinWnd = FindWindow(vbNullString, Ret)
LOOP

das ganze system hängt und es kommt gar nicht zum start des IE, weil die DO-LOOP Schleife alle CPU-Ressourcen in Anspruch nimmt…

[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]

ruf mal DoEvents auf ;o)