Solved

How do you check the url of a favourite in IE

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SLMGR Switches Are Not Working On KMS Host 3 90
Spell Check in VB6 13 112
Added a column screws up code 5 57
Problem to With line 4 57
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

786 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