-
How would one open up a new window for a bunch of links in the default browser? I have a listbox of links, and I want to start a new browser for each of the links. It has to be in the default browser, though, not just a specific path. Help would be appreciated, and I'll give you the program for free if you want.
Thanks,
bob
-
Try the ShellExecute API, ie.
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 0, "OPEN", "http://www.vb-world.net", "", "", 1
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
I've already tried that, but it has to open up more than one window. I have a list of things that each has to be shelled in a new window. What you gave me only opens those links in one window, so it in effect only opens the last one on the list. If only there was a way I could "open in new window" instead of just "open"
-
OK, what you can do is get the Path to the Default Browser, by Checking the Command Key for the HTM Extension, here's a Wrapper Sub I've Written to do the Job for you:
Code:
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Sub ShellNewBrowser(ByVal URL As String, Optional ByVal ShowWindowState As VbAppWinStyle = vbNormalFocus)
Dim lRegKey As Long
Dim sBrowser As String
Dim sData As String * 255
Dim lData As Long
If RegOpenKey(HKEY_CLASSES_ROOT, "htmlfile\shell\open\command", lRegKey) = 0 Then
lData = 255
Call RegQueryValueEx(lRegKey, "", 0&, 0&, ByVal sData, lData)
sBrowser = Left(sData, lData - 1)
Call RegCloseKey(lRegKey)
End If
Shell sBrowser & " <A HREF="http://"" TARGET=_blank>http://"</A> & URL, ShowWindowState
End Sub
Usage:
ShellNewBrowser "www.vb-world.net"
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
This is exactly what I wanted. Absolutely perfect. Thank you thank you thank you.