Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do you check the url of a favourite in IE

Posted on 2004-09-24
3
Medium Priority
?
226 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses

618 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