-
September 5th, 1999, 01:42 AM
#1
launching URLs from a VB app, is it possible ?
i am interested in launching a webpage via visual basic app
i am using visual basic 4.0 professional edition
thanks
-
September 6th, 1999, 01:39 AM
#2
Re: launching URLs from a VB app, is it possible ?
use the ShellExecute API:
ShellExecute(..., "yourpage.htm",...,"open", SW_SHOWNORMAL)
...will launch the browser and display the given HTML page or ASP.
-
December 5th, 1999, 04:12 PM
#3
Re: launching URLs from a VB app, is it possible ?
Code:
'DECLARATION:
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 Const SW_SHOWNORMAL = 1
'WEBPAGE:
Private Sub Command1_Click()
Dim lRet As Long
Dim sText As String
sText = "http://www.codeguru.com"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to start Web browser !"
End If
End Sub
'EMAIL:
Private Sub Command2_Click()
Dim lRet As Long
Dim sText As String
sText = "mailto:webmaster@codeguru.com"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to start email client!"
End If
End Sub
'ANY FILE:
Private Sub Command3_Click()
Dim lRet As Long
Dim sText As String
sText = "c:\test.txt"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to open file!"
End If
End Sub
[Cimperiali colorized for better reading]
Last edited by Cimperiali; December 7th, 2002 at 05:33 AM.
-
July 29th, 2006, 08:05 PM
#4
Re: launching URLs from a VB app, is it possible ?
It's fine, but I have a dude:
If I have 2 or more internet browser instance's , how choose other than last. ???
I supuse what it must work with lpParameters, re-knowing number instance and comparing path.
Any knows how do it ??.
-
January 13th, 2007, 06:01 AM
#5
Re: launching URLs from a VB app, is it possible ?
I have used the above code;
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
in Visual Basic 5 for meny years.
I have just updated from Visual Basic 5 to Visual Basic 2005 Express Edition and tois code no longer works.
I use it to load a help/information file from my application.
Dose anybody know any new code?
Mark Agius, Sussex, England.
-
January 13th, 2007, 06:05 AM
#6
Re: launching URLs from a VB app, is it possible ?
Try this
Code:
Imports System.Diagnostics
Public Module modmain
Sub Main()
Dim NewProcess as Process = new Process
NewProcess.Start("C:\MyApplication.exe")
End Sub
End Module
And call this module in button click event
-
July 22nd, 2007, 05:52 PM
#7
Re: launching URLs from a VB app, is it possible ?
Code:
'DECLARATION:
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 Const SW_SHOWNORMAL = 1
'WEBPAGE:
Private Sub Command1_Click()
Dim lRet As Long
Dim sText As String
sText = "http://www.codeguru.com"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to start Web browser !"
End If
End Sub
'EMAIL:
Private Sub Command2_Click()
Dim lRet As Long
Dim sText As String
sText = "mailto:webmaster@codeguru.com"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to start email client!"
End If
End Sub
'ANY FILE:
Private Sub Command3_Click()
Dim lRet As Long
Dim sText As String
sText = "c:\test.txt"
lRet = ShellExecute(hwnd, "open", sText, vbNull, vbNull, SW_SHOWNORMAL)
If lRet >= 0 And lRet <= 32 Then
MsgBox "Unable to open file!"
End If
End Sub
[Cimperiali colorized for better reading]
does shellexecute work in the same way in vb6?
-
July 22nd, 2007, 07:07 PM
#8
Re: launching URLs from a VB app, is it possible ?
that is vb6 code. the above 2 posts were hijacked from the OP, much like you did.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|