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




Sempel visual basic code soutrce Mouse Pointer in the middle of control
Sub CenterCursor(hWnd As Long)
Dim rPosition As RECT
#If Win32 Then
Dim X As Long
Dim Y As Long
#Else
Dim X As Integer
Dim Y As Integer
#End If

GetWindowRect hWnd, rPosition
X = (rPosition.right + rPosition.left) / 2
Y = (rPosition.bottom + rPosition.top) / 2
SetCursorPos X, Y
End Sub

CenterCursor hWnd:=Command1.hWnd

Sempel visual basic code soutrce Mouse Pointer in the middle of control

#If Win32 Then
Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Declare Sub GetWindowRect Lib "User32" (ByVal hWnd As _
Long, lpRect As RECT)
Declare Sub SetCursorPos Lib "User32" (ByVal X As _
Long, ByVal Y As Long)
#Else
Type RECT
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type

Declare Sub GetWindowRect Lib "User" (ByVal hWnd _
As Integer, lpRect As RECT)
Declare Sub SetCursorPos Lib "User" (ByVal X As _
Integer, ByVal Y As Integer)
#End If