Solved

Access IE History file from VB

Posted on 1998-10-19
5
164 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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 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…

830 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