i am interested in launching a webpage via visual basic app
i am using visual basic 4.0 professional edition
thanks
Printable View
i am interested in launching a webpage via visual basic app
i am using visual basic 4.0 professional edition
thanks
use the ShellExecute API:
ShellExecute(..., "yourpage.htm",...,"open", SW_SHOWNORMAL)
...will launch the browser and display the given HTML page or ASP.
[Cimperiali colorized for better reading]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
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 ??.
I have used the above code;
in Visual Basic 5 for meny years.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
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? :confused:
Quote:
Mark Agius, Sussex, England.
Try this
And call this module in button click eventCode:Imports System.Diagnostics
Public Module modmain
Sub Main()
Dim NewProcess as Process = new Process
NewProcess.Start("C:\MyApplication.exe")
End Sub
End Module
does shellexecute work in the same way in vb6?Quote:
[Cimperiali colorized for better reading]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
that is vb6 code. the above 2 posts were hijacked from the OP, much like you did. :(