VB Launch File or URL
What does this code do?
Runs an application or lauch a URL as long as the correct file association is set up on the client machine.
In other words a .exe file will run, a .txt file will open Notepad a web page will be displayed in the default browser.
How do I integrate it with my existing code?
Put the following in the (Declarations) section of the MODULE:
' Launch web pages declaration
Public Const SW_SHOW = 1
Public Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
' End launch web pages declaration
In the module include the following subroutine:
Public Sub Navigate(frm As Form, ByVal PathURL As String)
Dim hBrowse As Long
hBrowse = ShellExecute(frm.hwnd, "open", PathURL, "", "", SW_SHOW)
' to call from a form use, Navigate Me, "http://www.microsoft.com"
End Sub
To use from any form use Navigate Me, "URL or path and file", for example:
Navigate Me, "http://www.microsoft.com"
Navigate Me, "C:\My Documents\readme.txt"
Is there any similar code?
This code was built from an example on the Visual Basic Thunder site.
What controls and DLLs does it need?
None.
What version of Visual Basic was the code built with?
I am using Visual Basic 5 Professional with Visual Studio service pack 3 installed.
Assistance?
If you have any questions, comments or improvements, please e-mail me. I can't promise to answer all mails, but I do read them all and I will try to help if I have the time.
John C. Brown, 1998, http://www.clue.demon.co.uk