[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do you check the url of a favourite in IE

Posted on 2004-09-24
3
Medium Priority
?
227 Views
Last Modified: 2008-01-09
I'm trying to find the URL of a favourite in IE, automatically using vb.

Here is an example of the code i have been using:

Set oShortCut = wshshell.CreateShortcut(strIEFavourites & "\" & oFile.Name)

'Check shortcut target/TargetPath property
If oShortCut.TargetPath <> strFavouritePath Then

'etc .....

The oShortCut.TargetPath does not work as it is used to find the target path of shortcuts.  What is it to find the URL in favourites please?

 


       
0
Comment
Question by:willwatters
3 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12144198
Private Sub Command1_Click()
   Dim WshShell As Object
   Dim strDesktop As String
   Dim oMyShortCut As Object
   
   Set WshShell = CreateObject("Wscript.shell")
   If (WshShell Is Nothing) Then Exit Sub
   strDesktop = WshShell.SpecialFolders("Desktop")
   Set oMyShortCut = WshShell.CreateShortcut(strDesktop + "\Sample.lnk")
   oMyShortCut.WindowStyle = 4  '3- Maximized 7=Minimized  4=Normal
   'oMyShortcut.IconLocation = "C:\myicon.ico"
   oMyShortCut.TargetPath = "%windir%\notepad.exe"
   oMyShortCut.Arguments = "c:\temp.txt"
   'oMyShortcut.Hotkey = "ALT+CTRL+F"
   oMyShortCut.Save
End Sub


http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20678568.html
0
 

Author Comment

by:willwatters
ID: 12158430
but what is it for favourites? TargetPath did not work. I want to find the URL of a favourite.
0
 
LVL 1

Accepted Solution

by:
VBtorment earned 100 total points
ID: 12162987
Yo willwaters
maybe this is usefull

Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInet As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Long

Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" (lpdwError As Long, ByVal lpszBuffer As String, lpdwBufferLength As Long) As Boolean

Private Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer

Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
' WinInet flags
Private Const INTERNET_FLAG_RELOAD = &H80000000 'read from wire even if locally cached
Private Const INTERNET_FLAG_KEEP_CONNECTION = &H400000    '// use keep-alive semantics
Private Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000    '// don't write this item to the cache

Private Const INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP = &H8000      ' // ex: https:' // to http:' //
Private Const INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = &H4000     ' // ex: http:' // to https:' //
Private Const INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = &H2000     ' // expired X509 Cert.
Private Const INTERNET_FLAG_IGNORE_CERT_CN_INVALID = &H1000       ' // bad common name in X509 Cert.
Private Const INTERNET_FLAG_NO_AUTH = &H40000                     ' // no automatic authentication handling
Private Const INTERNET_FLAG_NO_COOKIES = &H80000                  ' // no automatic cookie handling

Private Const HTTP_QUERY_CONTENT_LOCATION = 51


Public Function TryTheWire(szURL$) As Boolean
   Dim hInet As Long
   Dim hUrl As Long
   Dim Flags As Long
   Dim url As Variant
   '
   ' Try opening each URL in the collection, until one succeeds.
   '
   hInet = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0&)
   If hInet Then
      Flags = INTERNET_FLAG_KEEP_CONNECTION Or INTERNET_FLAG_NO_CACHE_WRITE Or INTERNET_FLAG_RELOAD Or _
              INTERNET_FLAG_NO_COOKIES Or _
              INTERNET_FLAG_IGNORE_CERT_DATE_INVALID Or INTERNET_FLAG_IGNORE_CERT_CN_INVALID Or INTERNET_FLAG_NO_AUTH Or _
              INTERNET_FLAG_NO_COOKIES
      hUrl = InternetOpenUrl(hInet, szURL$, vbNullString, 0, Flags, 0)
      If hUrl Then
         'MsgBox GetQueryInfo(hUrl, HTTP_QUERY_CONTENT_LOCATION)
         Call InternetCloseHandle(hUrl)
         TryTheWire = True
      End If
   End If
   Call InternetCloseHandle(hInet)
End Function


Public Sub ShowError()
    Dim lErr As Long, sErr As String, lenBuf As Long
    'get the required buffer size
    InternetGetLastResponseInfo lErr, sErr, lenBuf
    'create a buffer
    sErr = String(lenBuf, 0)
    'retrieve the last respons info
    InternetGetLastResponseInfo lErr, sErr, lenBuf
    'show the last response info
    Call FMain.AddToList(False, CStr(lErr) + ": " + sErr)
End Sub

Private Function GetQueryInfo(ByVal hHttpRequest As Long, ByVal iInfoLevel As Long) As String
Dim sBuffer         As String * 1024
Dim lBufferLength   As Long

    lBufferLength = Len(sBuffer)
    If HttpQueryInfo(hHttpRequest, iInfoLevel, ByVal sBuffer, lBufferLength, 0) Then
        GetQueryInfo = Left$(sBuffer, lBufferLength)
    Else
        MsgBox "error"
    End If
End Function


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question