Search for directory default browser

Diposting oleh Source Code Program | 19.14 | | 0 komentar »

"Search for directory default browser

Option Explicit
Private Declare Function FindExecutable Lib "shell32.dll" _
Alias "FindExecutableA" _
(ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal sResult As String) As Long

Private Const MAX_PATH As Long = 260
Private Const ERROR_FILE_SUCCESS As Long = 32

Private Function GetBrowserName(dwFlagReturned As Long) As String

Dim l_hFile As Long
Dim sResult As String

"html file created while the later will be called
sResult = Space$(MAX_PATH)
dwFlagReturned = FindExecutable("dummy.html", App.Path, sResult)

"delete a file that is created
Kill App.Path & "\dummy.html"

"capture the location of executable files and dispose of character carridge return
GetBrowserName = TrimNull(sResult)

End Function

Private Sub Command1_Click()

Dim l_Temp As Long
Dim sBrowser As String

sBrowser = GetBrowserName(l_Temp)

Select Case l_Temp
Case Is >= ERROR_FILE_SUCCESS
MsgBox "Location of default browser: " & sBrowser, vbInformation
Case Else
MsgBox "Can't find default browser", vbInformation
End Select
End Sub




0 komentar