|
-
Feb 21st, 2003, 02:35 AM
#1
Thread Starter
Addicted Member
Webpage Info : Real Urgent
Friends,
I have attached a vb6 project which enables to extract the names of webpages visited whose copies are being stored in the History folder.
I want to know how do we get the Tag Information , the content and the last time it was accessed/modified. This may be applied for the cookies even.
I am still giving the code if anyone can help me out please.
Code:
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const ERROR_CACHE_FIND_FAIL As Long = 0
Const ERROR_CACHE_FIND_SUCCESS As Long = 1
Const ERROR_FILE_NOT_FOUND As Long = 2
Const ERROR_ACCESS_DENIED As Long = 5
Const ERROR_INSUFFICIENT_BUFFER As Long = 122
Const MAX_PATH As Long = 260
Const MAX_CACHE_ENTRY_INFO_SIZE As Long = 4096
Const LMEM_FIXED As Long = &H0
Const LMEM_ZEROINIT As Long = &H40
Const LPTR As Long = (LMEM_FIXED Or LMEM_ZEROINIT)
Const NORMAL_CACHE_ENTRY As Long = &H1
Const EDITED_CACHE_ENTRY As Long = &H8
Const TRACK_OFFLINE_CACHE_ENTRY As Long = &H10
Const TRACK_ONLINE_CACHE_ENTRY As Long = &H20
Const STICKY_CACHE_ENTRY As Long = &H40
Const SPARSE_CACHE_ENTRY As Long = &H10000
Const COOKIE_CACHE_ENTRY As Long = &H100000
Const URLHISTORY_CACHE_ENTRY As Long = &H200000
Const URLCACHE_FIND_DEFAULT_FILTER As Long = NORMAL_CACHE_ENTRY Or _
COOKIE_CACHE_ENTRY Or _
URLHISTORY_CACHE_ENTRY Or _
TRACK_OFFLINE_CACHE_ENTRY Or _
TRACK_ONLINE_CACHE_ENTRY Or _
STICKY_CACHE_ENTRY
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type INTERNET_CACHE_ENTRY_INFO
dwStructSize As Long
lpszSourceUrlName As Long
lpszLocalFileName As Long
CacheEntryType As Long
dwUseCount As Long
dwHitRate As Long
dwSizeLow As Long
dwSizeHigh As Long
LastModifiedTime As FILETIME
ExpireTime As FILETIME
LastAccessTime As FILETIME
LastSyncTime As FILETIME
lpHeaderInfo As Long
dwHeaderInfoSize As Long
lpszFileExtension As Long
dwExemptDelta As Long
End Type
Private Declare Function FindFirstUrlCacheEntry Lib "wininet" _
Alias "FindFirstUrlCacheEntryA" _
(ByVal lpszUrlSearchPattern As String, _
lpFirstCacheEntryInfo As Any, _
lpdwFirstCacheEntryInfoBufferSize As Long) As Long
Private Declare Function FindNextUrlCacheEntry Lib "wininet" _
Alias "FindNextUrlCacheEntryA" _
(ByVal hEnumHandle As Long, _
lpNextCacheEntryInfo As Any, _
lpdwNextCacheEntryInfoBufferSize As Long) As Long
Private Declare Function FindCloseUrlCache Lib "wininet" _
(ByVal hEnumHandle As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(pDest As Any, _
pSource As Any, _
ByVal dwLength As Long)
Private Declare Function lstrcpyA Lib "kernel32" _
(ByVal RetVal As String, ByVal Ptr As Long) As Long
Private Declare Function lstrlenA Lib "kernel32" _
(ByVal Ptr As Any) As Long
Private Declare Function LocalAlloc Lib "kernel32" _
(ByVal uFlags As Long, _
ByVal uBytes As Long) As Long
Private Declare Function LocalFree Lib "kernel32" _
(ByVal hMem As Long) As Long
'--end block--'
Private Sub Form_Load()
With Combo1
.AddItem "Normal Entry"
.ItemData(.NewIndex) = &H1
.AddItem "Edited Entry (IE5)"
.ItemData(.NewIndex) = &H8
.AddItem "Offline Entry"
.ItemData(.NewIndex) = &H10
.AddItem "Online Entry"
.ItemData(.NewIndex) = &H20
.AddItem "Stick Entry"
.ItemData(.NewIndex) = &H40
.AddItem "Sparse Entry (n/a)"
.ItemData(.NewIndex) = &H10000
.AddItem "Cookies"
.ItemData(.NewIndex) = &H100000
.AddItem "Visited History"
.ItemData(.NewIndex) = &H200000
.AddItem "Default Filter"
.ItemData(.NewIndex) = URLCACHE_FIND_DEFAULT_FILTER
.ListIndex = 0
End With
End Sub
Private Sub Command1_Click()
Dim numEntries As Long
Dim cacheType As Long
cacheType = Combo1.ItemData(Combo1.ListIndex)
Label1.Caption = "Working ..."
Label1.Refresh
List1.Clear
List1.Visible = False
numEntries = GetCacheURLList(cacheType)
List1.Visible = True
Label1.Caption = Format$(numEntries, "###,###,###,##0") & "files found"
End Sub
Private Sub Form_Resize()
List1.Width = Me.Width - 500
Text1.Width = Me.Width - 500
End Sub
Private Sub List1_Click()
Text1.Text = List1.List(List1.ListIndex)
End Sub
Private Function GetCacheURLList(cacheType As Long) As Long
Dim ICEI As INTERNET_CACHE_ENTRY_INFO
Dim hFile As Long
Dim cachefile As String
Dim nCount As Long
Dim dwBuffer As Long
Dim pntrICE As Long
'Like other APIs, calling FindFirstUrlCacheEntry or
'FindNextUrlCacheEntry with an insufficient buffer will
'cause the API to fail, and its dwBuffer points to the
'correct size required for a successful call.
dwBuffer = 0
'Call to determine the required buffer size
hFile = FindFirstUrlCacheEntry(vbNullString, ByVal 0, dwBuffer)
'both conditions should be met by the first call
If (hFile = ERROR_CACHE_FIND_FAIL) And _
(Err.LastDllError = ERROR_INSUFFICIENT_BUFFER) Then
'The INTERNET_CACHE_ENTRY_INFO data type is a
'variable-length type. It is necessary to allocate
'memory for the result of the call and pass the
'pointer to this memory location to the API.
pntrICE = LocalAlloc(LMEM_FIXED, dwBuffer)
'allocation successful
If pntrICE Then
'set a Long pointer to the memory location
CopyMemory ByVal pntrICE, dwBuffer, 4
'and call the first find API again passing the
'pointer to the allocated memory
hFile = FindFirstUrlCacheEntry(vbNullString, ByVal pntrICE, dwBuffer)
'hfile should = 1 (success)
If hFile <> ERROR_CACHE_FIND_FAIL Then
'now just loop through the cache
Do
'the pointer has been filled, so move the
'data back into a ICEI structure
CopyMemory ICEI, ByVal pntrICE, Len(ICEI)
'CacheEntryType is a long representing the type of
'entry returned, and should match our passed param.
If (ICEI.CacheEntryType And cacheType) Then
'extract the string from the memory location
'pointed to by the lpszSourceUrlName member
'and add to a list
cachefile = GetStrFromPtrA(ICEI.lpszSourceUrlName)
List1.AddItem cachefile
nCount = nCount + 1
End If
'free the pointer and memory associated
'with the last-retrieved file
Call LocalFree(pntrICE)
'and again repeat the procedure, this time calling
'FindNextUrlCacheEntry with a buffer size set to 0.
'This will cause the call to once again fail,
'returning the required size as dwBuffer
dwBuffer = 0
Call FindNextUrlCacheEntry(hFile, ByVal 0, dwBuffer)
'allocate and assign the memory to the pointer
pntrICE = LocalAlloc(LMEM_FIXED, dwBuffer)
CopyMemory ByVal pntrICE, dwBuffer, 4
'and call again with the valid parameters.
'If the call fails (no more data), the loop exits.
'If the call is successful, the Do portion of the
'loop is executed again, extracting the data from
'the returned type
Loop While FindNextUrlCacheEntry(hFile, ByVal pntrICE, dwBuffer)
End If 'hFile
End If 'pntrICE
End If 'hFile
'clean up by closing the find handle, as
'well as calling LocalFree again to be safe
Call LocalFree(pntrICE)
Call FindCloseUrlCache(hFile)
GetCacheURLList = nCount
End Function
Private Function GetStrFromPtrA(ByVal lpszA As Long) As String
GetStrFromPtrA = String$(lstrlenA(ByVal lpszA), 0)
Call lstrcpyA(ByVal GetStrFromPtrA, ByVal lpszA)
End Function
'--end block--'
Add listbox, textbox, combobox and a command button on the form.
This is real urgent.
Please help me.
Suva --> The great VB 6.0 Programmer
Note :
If problem is Resolved dont forget to edit your first post and add RESOLVED to your subject
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|