?
Solved

How do you check the url of a favourite in IE

Posted on 2004-09-24
3
Medium Priority
?
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 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