Solved

Access IE History file from VB

Posted on 1998-10-19
5
171 Views
Last Modified: 2012-05-05
Does anyone know how to pull a history listing from IE 4.x using VB?
0
Comment
Question by:red_eye
[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
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
gencross earned 200 total points
ID: 1440692
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
 
LVL 4

Expert Comment

by:gencross
ID: 1440693
Is this what you are looking for?  I might have misunderstood.
0
 

Author Comment

by:red_eye
ID: 1440694
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
 
LVL 4

Expert Comment

by:gencross
ID: 1440695
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
 

Author Comment

by:red_eye
ID: 1440696
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 75
pop out of webbrowser1 control vba6 5 51
backup program with robocopy 6 90
Excel 2007 Random Generate List Based on Defined Source Cells 3 29
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

732 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