Solved

=========> Urgent Urgent Urgent <=========  log visited web site

Posted on 2006-07-14
5
212 Views
Last Modified: 2010-04-05
hi
i want source code for log all visited web site in a Workstation
0
Comment
Question by:mahdiparak
[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
  • 2
5 Comments
 
LVL 2

Expert Comment

by:insomniac92
ID: 17112911
what OS / browser?
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 17113326

This is from an old PAQ I worked on, assuming you are dealing with IE. If so, the code allows you to get all the visited urls, (and cookies, etc) that are currently in the history.

Regards,
Russell

Example usage (form, memo control, and a button)

procedure TForm1.Button1Click(Sender: TObject);
var  dwIndex:       Integer;
begin

  with TUrlCache.Create do
  begin
     GetEntries(utUrl, Memo1.Lines);
     MessageBox(0, 'Click ok to load cookies', nil, MB_OK);
     GetEntries(utCookie, Memo1.Lines);
     MessageBox(0, 'Click ok to load visited sites', nil, MB_OK);
     GetEntries(utVisited, Memo1.Lines);
     MessageBox(0, 'Click ok to load all urls', nil, MB_OK);
     GetEntries(utAll, Memo1.Lines);
     // Clear all urls if OK is clicked
     if (MessageBox(0, 'Click ok to clear cache', nil, MB_OKCANCEL) = ID_OK) then Clear;
     // Free object
     Free;
  end;

end;





Source:

--------------------
unit UrlCache;

interface

uses
  Windows, SysUtils, Classes, WinInet;

const
  DEF_URLSIZE       =  512;  // Average url size. This is used because the structure
                             // for the url entry will always be greater than 80 bytes,
                             // but in general, will be less than 512 bytes. This allows
                             // a balance between allocating too much memory, and having to
                             // perform a realloc on every enumeration call.

type
  TUrlEntryType     =  (utAll, utUrl, utCookie, utVisited);
  TUrlCache         =  class(TObject)
  private
     // Private declarations
     FList:         TList;
     procedure      ClearList;
  protected
     // Protected declarations
     function       GetUrlEntry(Index: Integer): TInternetCacheEntryInfo;
     function       GetCount: Integer;
     procedure      Load;
  public
     // Public declarations
     constructor    Create;
     destructor     Destroy; override;
     procedure      Delete(Index: Integer);
     procedure      Refresh;
     procedure      GetEntries(EntryType: TUrlEntryType; List: TStrings);
     procedure      Clear;
     property       Count: Integer read GetCount;
     property       UrlEntry[Index: Integer]: TInternetCacheEntryInfo read GetUrlEntry; default;
  end;

implementation

procedure TUrlCache.GetEntries(EntryType: TUrlEntryType; List: TStrings);
var  dwIndex:       Integer;
begin

  // Check list
  if Assigned(List) then
  begin
     // Clear list
     List.Clear;
     // Walk all items
     for dwIndex:=0 to Pred(FList.Count) do
     begin
        // Get the specified entry types
        case EntryType of
           // Url sites
           utUrl       :
           begin
              // Not visited: or cookies:
              if (StrLIComp('cookie:', PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName, 7) <> 0) and
                 (StrLIComp('visited:', PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName, 8) <> 0) then
              begin
                 List.Add(PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName);
              end;
           end;
           // Add "cookies:" entries
           utCookie    :
           begin
              if (StrLIComp('cookie:', PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName, 7) = 0) then
              begin
                 List.Add(PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName);
              end;
           end;
           // Add "visited:" entries
           utVisited   :
           begin
              if (StrLIComp('visited:', PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName, 8) = 0) then
              begin
                 List.Add(PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName);
              end;
           end;
        else
           // Add the entry
           List.Add(PInternetCacheEntryInfo(FList[dwIndex])^.lpszSourceUrlName);
        end;
     end;
  end;

end;

function TUrlCache.GetCount: Integer;
begin

  // Return entry count
  result:=FList.Count;

end;

procedure TUrlCache.ClearList;
var  dwIndex:       Integer;
begin

  // Free all entries and clear the list
  for dwIndex:=Pred(FList.Count) downto 0 do
  begin
     // Free memory
     FreeMem(FList[dwIndex]);
  end;

  // Clear the list
  FList.Clear;

end;

function TUrlCache.GetUrlEntry(Index: Integer): TInternetCacheEntryInfo;
begin

  // Return the requested entry
  result:=PInternetCacheEntryInfo(FList[Index])^;

end;

procedure TUrlCache.Delete(Index: Integer);
begin

  // Remove from cache
  if DeleteUrlCacheEntry(PInternetCacheEntryInfo(FList[Index]).lpszSourceUrlName) then
  begin
     // Free memory
     FreeMem(FList[Index]);
     // Remove from list
       FList.Delete(Index);
  end;

end;

procedure TUrlCache.Refresh;
begin

  // Just call load
  Load;

end;

procedure TUrlCache.Load;
var  lpCacheEntry:  PInternetCacheEntryInfo;
     hFind:         THandle;
     dwSize:        DWORD;
     bEnum:         Boolean;
begin

  // Allocate memory for the find
  dwSize:=DEF_URLSIZE;
  lpCacheEntry:=AllocMem(dwSize);

  // Find first
  hFind:=FindFirstUrlCacheEntry(nil, lpCacheEntry^, dwSize);
  if (hFind = 0) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) then
  begin
     // Reallocate for required size
     ReAllocMem(lpCacheEntry, dwSize);
     // Perform find again
     hFind:=FindFirstUrlCacheEntry(nil, lpCacheEntry^, dwSize);
  end;

  // Set enum state
  bEnum:=(hFind <> 0);

  // Perform find first/next enumeration
  if bEnum then
  begin
     // Find has started
     while bEnum do
     begin
        // Add entry to list
        FList.Add(lpCacheEntry);
        // Nil the pointer
        lpCacheEntry:=nil;
        // Allocate for find next
        dwSize:=DEF_URLSIZE;
        lpCacheEntry:=AllocMem(dwSize);
        // Find next
        if not(FindNextUrlCacheEntry(hFind, lpCacheEntry^, dwSize)) then
        begin
           // Buffer too small, or no more items?
           if (GetLastError = ERROR_INSUFFICIENT_BUFFER) then
           begin
              // Reallocate for required size
              ReAllocMem(lpCacheEntry, dwSize);
              // Perform find next again
              bEnum:=FindNextUrlCacheEntry(hFind, lpCacheEntry^, dwSize);
           end
           else
              // Done enumeration
              bEnum:=False;
        end
        else
           // Enumerate
           bEnum:=True;
     end;
     // Close the enumeration
     FindCloseUrlCache(hFind);
  end;

  // If entry is assigned then free memory
  if Assigned(lpCacheEntry) then FreeMem(lpCacheEntry);

end;

procedure TUrlCache.Clear;
var  dwIndex:       Integer;
begin

  // This will delete all entries from the cache
  for dwIndex:=Pred(FList.Count) downto 0 do
  begin
     // Remove from cache
     if DeleteUrlCacheEntry(PInternetCacheEntryInfo(FList[dwIndex]).lpszSourceUrlName) then
     begin
        // Free memory
        FreeMem(FList[dwIndex]);
        // Remove from list
        FList.Delete(dwIndex);
     end;
  end;
  if FList.Count > 0 then
     beep;
end;

constructor TUrlCache.Create;
begin

  // Perform inherited
  inherited Create;

  // Create list
  FList:=TList.Create;

  // Load the list
  Load;

end;

destructor TUrlCache.Destroy;
begin

  // Clear all entries from the list
  try
     ClearList;
  finally
     // Free the list
     FList.Free;
  end;

  // Perform inherited
  inherited Destroy;

end;

end.
0
 
LVL 1

Author Comment

by:mahdiparak
ID: 17113783
excellent Rllibby
very thanks
0
 
LVL 1

Author Comment

by:mahdiparak
ID: 17129381
ok
not use again.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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