Is there a way to open a URL in VB6 application without using Webbrowser or MSInet components? thanks
2 Answers
If you just want to open the URL in a browser window, then use ShellExecute: http://support.microsoft.com/kb/224816
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()
Dim r As Long
r = ShellExecute(0, "open", "http://www.microsoft.com", 0, 0, 1)
End Sub
This will open the URL in the default browser.
Otherwise, if you need to display the webpage inside your app, use the WebBrowser control.
-
thansks, as I stated in question I want to open a web page in VB6 application and without using WebBrowser, as it would require me to redistribute this .ocx with my executable which I'm currently forbidden to do.(project management stuff) Jul 30, 2012 at 5:41
-
I don't think that OCX(for WebBrowser control) needs to be distributed along with your app. PC with IE installed would have that OCX, I believe. My VB is a bit rusty. So, do a test run. What kind of operation are you doing with the app? If you don't like the classic Package&Deployment of VB, then you could make use of the free Inno Setup compiler to create the setup file for your app. Jul 30, 2012 at 6:33
-
It needs the OCX to be distributed. Unfortunately I am allowed to place only single file (be it .exe or other) as my application on a virtual server where it's going to be used. Jul 30, 2012 at 8:45
-
1The control does need the OCX to be redistributed but
ShellExecute()
does not need the control. It just needs some web browser installed on the computer. The "single file" is a pretty arbitrary and stupid restriction though, epsecially as any VB6 apps need at least 5 other runtime DLLs to be installed.– DeannaJul 30, 2012 at 11:04 -
@Deanna it is something to be used for penetration testing, and is very much reasonable restriction. I don't want to go into details, but that's just how it is. Jul 31, 2012 at 12:04
No. VB6 does not have any intrinsic means of displaying a web page in an application. You have to use a third party control. On the other hand, this shouldn't be a problem, because you are essentially using a component of Microsoft Internet Explorer. In fact, you should not be distributing this control, because you would likely damage the end user's Windows installation.