Often, you may want a user to access a specific URI on the Web by
launching his default browser and navigating to the Web site of your
choice. Fortunately, a simple Windows API function ShellExecute() lets
you do just that. When you pass this function a filename, it uses the
Windows file associations to start the appropriate application. As a
result, all you need do is pass this function a URI, and it automatically
launches the default browser and navigates to the requested location.
The ShellExecute() function conforms to the following syntax:Private 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
As you can see, it takes quite a few parameters, but don't worry, for our
purposes only two concern us: lpFile and nShowCmd. The lpFile parameter
holds the name of the file or application you want to launch, while the
nShowCmd parameter contains directions indicating how you want the
application to appear when it opens. Typically, you'll use the SW_SHOWNORMAL
constant (1).
So for instance, to use this function to navigate to a Web page with the
URI www.google.com, you'd write code along the lines of:
ShellExecute 0&, vbNullString, "www.google.com", vbNullString,
_
vbNullString, SW_SHOWNORMAL
If for any reason the ShellExecute() doesn't execute the application
properly, the function returns a value less than or equal to 32. Otherwise,
it returns a value that points to the launched application.
Launch a PC's default browser
By ElementK Journals, published on 14 Jul 2001
| Filed in
You might also like...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments