Solved

How do you check the url of a favourite in IE

Posted on 2004-09-24
3
210 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 50 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

856 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