Solved

Access IE History file from VB

Posted on 1998-10-19
5
152 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
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
gencross earned 200 total points
Comment Utility
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
Comment Utility
Is this what you are looking for?  I might have misunderstood.
0
 

Author Comment

by:red_eye
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now