'*******************************************
' Running default webbrowser and sending email - by DarKPaiN
'
'w w w . P r o g e n i c . c o m
'*******************************************

'#########################
'# PLace this code in a Form
'# Create 1 button, set the caption to www
'# Create 1 button, set the caption to Email
'#########################

Private Sub Command1_Click()
Dim success As Integer

    Site = "http://www.MyWebPage.com"          '// Change this to your website and page
    success% = ShellToBrowser(Me, Site, 0)     '// Calls the shell to browser function
End Sub



Private Sub Command2_Click()
Dim success As Integer

    Site = "mailto:MyMailAddress@MyMailServer.com"   '// Change this to your mail address
    success% = ShellToBrowser(Me, Site, 0)           '// Calls the shell to browser function
End Sub


'#########################
'# PLace this code in a Module
'#########################




Declare Function GetTickCount Lib "kernel32" () As Long

Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
    Dim api%
        api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
        If api% < 31 Then
            MsgBox App.Title & " had a problem running your web browser.You should check that your browser is correctly installed.(Error" & Format$(api%) & ")", 48, "Browser Unavailable"
            ShellToBrowser% = False
        ElseIf api% = 32 Then
            MsgBox App.Title & " could not find a file association for " & URL$ & " on your system. You should check that your browser is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
            ShellToBrowser% = False
        Else
            ShellToBrowser% = True
        End If
End Function
