Hey guys,
I'm using kleinma's code to open a web browser after a user
installs the software that goes to a thank you page on my
site. I wanted to have it launch a few seconds after install
in their default browser which is why I'm using this code below.
I put in a timer into the form but am unfamiliar with how to
use it specifically with kleinma's code.
Anyone know how I can do this? And also specify the height
and width of the page?
vb Code:
Public Sub LaunchNewBrowser(ByVal strUrl As String) Try 'CREATE SOME VARIABLES Dim BrowserExec As String = New String(" "c, 255) Dim FileName As String Dim RetVal As Long Dim SWriter As StreamWriter 'CREATE A TEMP HTM FILE SO WE CAN FIND OUT WHAT BROWSER IS 'THE DEFAULT ONE ON THE SYSTEM FileName = Application.StartupPath & "\temp.htm" Try SWriter = File.CreateText(FileName) SWriter.Write("<html></html>") SWriter.Close() Catch ex As Exception 'IF ANYTHING GOES WRONG, TRY TO DO A STANDARD PROCESS LAUNCH BackupLaunch(strUrl) Return End Try 'CALL THE API TO FIND THE EXE ASSOCIATED WITH HTM FILES RetVal = FindExecutable(FileName, vbNullString, BrowserExec) BrowserExec = BrowserExec.Trim 'IF WE GET ONE, LAUNCH THE URL IN THE NEW INSTANCE OF THE BROWSER If RetVal <= 32 OrElse BrowserExec = String.Empty Then MessageBox.Show("Could not find a valid web browser") Else Process.Start(BrowserExec, New UriBuilder(strUrl).Uri.AbsoluteUri) End If Try 'DELETE THAT PESKY TEMP FILE File.Delete(FileName) Catch ex As Exception 'NOT GOING TO DO ANYTHING, MIGHT WANT TO LOG IT OR SOMETHING End Try Catch ex As Exception 'IF ANYTHING GOES WRONG, TRY TO DO A STANDARD PROCESS LAUNCH BackupLaunch(strUrl) End Try End Sub 'THIS IS USED INCASE THE MAIN ROUTINE FAILS, SO WE TRY TO AT LEAST TO THE LAUNCH ANYWAY, 'EVEN THOUGH IT WILL BE IN AN ALREADY OPEN WINDOW. ITS A SECOND SUB BC ITS USED MORE THAN 'ONCE IN THE MAIN ROUTINE Private Sub BackupLaunch(ByVal strURL As String) Try Process.Start(strURL) Catch ex As Exception MessageBox.Show("Could not launch website. Error Unknown.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Module
Chris




Reply With Quote