Tipp 5.29 - Pfad Standard-Browser ermitteln
Wie kann ich den Pfad des Standard-Browser ermitteln?
Mit dieser Funktion können Sie den Pfad des Standard-Browser ermitteln. Kopieren Sie einfach nachfolgenden Quellcode in die Zwischenablage und fügen Sie anschließend den Inhalt der Zwischenablage in ein neues Modul ein. Die Aufrufparameter finden Sie im Quellcode beschrieben.
Verwendete Win32-Api-Aufrufe und Typen: FindExecutable
Beispiel:
Option Explicit Declare Function FindExecutable Lib "shell32.dll" Alias _ "FindExecutableA" _ (ByVal lpFile As String, _ ByVal lpDirectory As String, _ ByVal lpResult As String) As Long Sub DefaultBrowser() '// ----------------------------------------------------- '// Rückgabe: | Ermittelt den Pfad des Standardbrowsers '// ----------------------------------------------------- '// Autor: | Stefan Kulpa '// | EDV Innovation & Consulting - Dormagen '// ----------------------------------------------------- Dim sTmpFile As String Dim sBuffer As String Dim sFolder As String Dim sFile As String Dim sMsg As String Dim lResult As Long Dim iFile As Integer sFile = "MyDummy.htm" sFolder = Environ("TEMP") sTmpFile = sFolder If Right(sTmpFile, 1) <> "\" Then sTmpFile = sTmpFile & "\" End If sTmpFile = sTmpFile & sFile iFile = FreeFile Open sTmpFile For Output As #iFile Print #iFile, "<HTML> <HTML>" Close #iFile sBuffer = Space(255) lResult = FindExecutable(sFile, sFolder, sBuffer) sBuffer = Trim(sBuffer) If lResult <= 32 Or IsEmpty(sBuffer) Then sMsg = "Es konnte kein Standard-Browser ermittelt werden!" MsgBox sMsg, vbExclamation Else sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1) sMsg = "Der Es konnte folgender Standard-Browser " & _ "ermittelt werden:" & vbCrLf & sBuffer MsgBox sMsg, vbInformation End If If Dir(sTmpFile) <> "" Then Kill sTmpFile End Sub