Access IE History file from VB

Does anyone know how to pull a history listing from IE 4.x using VB?
red_eyeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
gencrossConnect With a Mentor Commented:
You need to use API Registry calls to do this.  The history of IE pages is under
HKEY_CURRENT_USER "Software\microsoft\Internet Explorer\TypedURLs"

The easiest way to do this would be to enumerate the keys (Url1) and the values (www.microsoft.com).  This will put all values and keys into a double dimensioned variant array.  You can get at them from there.  

I have a class that will do exactly what you are looking for, and a lot more if you would like it.  Here are a list of the API registry declares.  You won't need all of these to do what you want to do, but here they are.

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" _
        (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
        ByVal samDesired As Long, phkResult As Long) As Long

Private Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" _
        (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
       ByVal dwType As Long, ByVal szData As String, ByVal cbData As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
        (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
       ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long

Private Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" _
        (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, _
       ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, _
       lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, _
       lpdwDisposition As Long) As Long

Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" _
        (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _
       lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, _
       lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long

Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" ( _
       ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _
       ByVal cbName As Long) As Long

Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" _
        (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, _
       lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, _
       ByVal lpData As String, lpcbData As Long) As Long

Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" _
        (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" _
        (ByVal hKey As Long, ByVal lpValueName As String) As Long

0
 
gencrossCommented:
Is this what you are looking for?  I might have misunderstood.
0
 
red_eyeAuthor Commented:
The typed URL history would be of help but what I am also looking for is access to the URL history in the C:\windows\history folder. Any ideas on this? I am sorry I wasnt more clear with my question. I have increased the points to 175.
0
 
gencrossCommented:
I think this might be what you are looking for.  This code will pull all urls out of the index.dat file in the c:\windows\history folder and print them in the debug window.  You can put them in an array or whatever.  You can modify this code if you need to get into the other dat files in that directory, but this one should be all you need.

Put this code in form load or button click or something...

Dim displacement As Integer
Dim dta As String
Dim i As Long
Dim j As Long

displacement = 119

Open "c:\windows\history\index.dat" For Binary As #1

dta = Space$(LOF(1))

Get #1, , dta

Close #1

i = InStr(i + 1, dta, "URLS ")

While i < Len(dta)
 
  If i > 0 Then
    j = InStr(i + displacement - 1, dta, Chr$(0))
    Debug.Print Mid$(dta, i + displacement, j - (i + displacement))
'  If i = 372481 Then Stop
  End If
 
  i = InStr(i + 1, dta, "URL ")
 
  If i = 0 Then End
 
Wend

End

I hope this is the correct answer.  If not then let me know.
0
 
red_eyeAuthor Commented:
PERFECT! Thank you very much! That is exactly what I was looking for. I bumped the point total to 200 for providing the actual working code which will be a great base to work from!! I will keep you in mind when the app goes into beta to see if you are interested in testing it. Thanks again!
0
All Courses

From novice to tech pro — start learning today.