Using API, How do I make it popup to what URL they type into a textbox using the default browser?
Printable View
Using API, How do I make it popup to what URL they type into a textbox using the default browser?
VB Code:
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 Private Sub Command1_Click() ShellExecute Me.hwnd, "open", Text1.Text, vbNullString, vbNullString, 1 End Sub
hmm you can make the page show up in internet explorer like
There must be an API to get the default browser location, this thread should be in the API section :)VB Code:
'textbox holds [url]http://www.google.com[/url] Private_Sub Command1_Click() Shell "explorer.exe " & Text1.Text End Sub
Alright, Thanks...is there anyway that you guys know of w/o using api then?
The above method works without API but it only lauches the web page from internet explorer, not the default browser, hmm...i'm pretty sure the default web browser is saved in the registry somewhere, so if you could find the registry key (google it) you could simple read the default browser path from the registry and replace the "explorer.exe " with the path
why wouldnt it be "iexplore.exe"?
Jmacp show you how to do it with an API (ShellExecute). But if you really don't want to use that (for some reason) this should also work (but it isn't that nice):VB Code:
Shell Environ("COMSPEC") & " /c Start " & Text1.Text, vbHide
If you use iexplore.exe it gives path not found error. It accepts explorer.exe and explorer because explorer.exe is the file which is used to view folders (among other OS things), so when you try to view a folder which is a web page, because windows is by microsoft, they launch their web browser..which as you know is internet explorer
o ok, thank you