Solved

Deleting browser history etc using Delphi 3

Posted on 2003-11-22
15
552 Views
Last Modified: 2010-04-05
I need functions (or a D3 component) for deleting the history and temporary internet files (and maybe cookies) from any of the major browsers such as Internet Explorer, Netscape, Opera, etc.

I use Delphi 3. There is a component (http://www.euromind.com/iedelphi/) but this is for Delphi 4, 5, 6.

I use Windows XP. I know nothing about the internal workings of XP so I would like  function/s which I can simply copy/paste. In other words, something for a beginner.

When the user closes my program, history etc should be deleted if a checkbox is ticked.

Thanks for your help.
0
Comment
Question by:rincewind666
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 9

Assisted Solution

by:ginsonic
ginsonic earned 400 total points
ID: 9805216
procedure DeleteCache;
var
 lpEntryInfo: PInternetCacheEntryInfo;
 hCacheDir: LongWord;
 dwEntrySize: LongWord;
begin
 dwEntrySize := 0;
 FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
 GetMem(lpEntryInfo, dwEntrySize);
 if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
 hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
 if hCacheDir <> 0 then begin
   repeat
     // delete cookies
     if ((lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY) = COOKIE_CACHE_ENTRY)
     // delete history
     or ((lpEntryInfo^.CacheEntryType and URLHISTORY_CACHE_ENTRY) = URLHISTORY_CACHE_ENTRY)
     // delete "normal" cache
     or ((lpEntryInfo^.CacheEntryType and NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY)
     then DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
     FreeMem(lpEntryInfo, dwEntrySize);
     dwEntrySize := 0;
     FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
     GetMem(lpEntryInfo, dwEntrySize);
     if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
   until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize);
 end;
 FreeMem(lpEntryInfo, dwEntrySize);
 FindCloseUrlCache(hCacheDir);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 9805220
I forgot ... must add at uses 'wininet'
0
 

Author Comment

by:rincewind666
ID: 9809339
I get the following 7 errors:

[A] Undeclared identifier: 'LongWord'.
[B] Types of actual and formal var parameters must be identical.
[C] Undeclared identifier: 'COOK_CACHE_ENTRY'.
[D] Undeclared identifier: 'URLHISTORY_CACHE_ENTRY'.


procedure DeleteCache;
var
 lpEntryInfo: PInternetCacheEntryInfo;
 hCacheDir: LongWord;                  [A]
 dwEntrySize: LongWord;
begin
 dwEntrySize := 0;
 FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize); [B]
 GetMem(lpEntryInfo, dwEntrySize);
 if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
 hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);     [B]
 if hCacheDir <> 0 then begin
   repeat
     // delete cookies
     if ((lpEntryInfo^.CacheEntryType and COOKIE_CACHE_ENTRY) = COOKIE_CACHE_ENTRY)                                                                    [C]
     // delete history
     or ((lpEntryInfo^.CacheEntryType and URLHISTORY_CACHE_ENTRY) = URLHISTORY_CACHE_ENTRY)                                                                     [D]
     // delete "normal" cache
     or ((lpEntryInfo^.CacheEntryType and NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY)
     then DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
     FreeMem(lpEntryInfo, dwEntrySize);
     dwEntrySize := 0;
     FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);  [B]
     GetMem(lpEntryInfo, dwEntrySize);
     if dwEntrySize > 0 then lpEntryInfo^.dwStructSize := dwEntrySize;
   until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize);        [B]
 end;
 FreeMem(lpEntryInfo, dwEntrySize);
 FindCloseUrlCache(hCacheDir);
end;
      

Thanks for your help. Much appreciated.

Regards
Chris Jones
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 9

Expert Comment

by:ginsonic
ID: 9812388
Can you check if in your'System.pas' unit have declared LongWord ?
0
 

Author Comment

by:rincewind666
ID: 9839587
There is no 'System.pas'
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 9841260
What version of D3 use? Personal, Pro or Enterprise?

\Program Files\Borland\DelphiXYZ\Source\Rtl\Sys where XYZ is your Delphi version
0
 

Author Comment

by:rincewind666
ID: 9841802
XYZ just says "Delphi 3"
About box says "Delphi Standard Version 3.0 (Build 5.83)"
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9842082
hCacheDir: DWORD; { or just longint }
dwEntrySize: DWORD; { or just longint }
0
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9842129
COOKIE_CACHE_ENTRY not COOK_CACHE_ENTRY
0
 
LVL 6

Accepted Solution

by:
GloomyFriar earned 100 total points
ID: 9842130
const
NORMAL_CACHE_ENTRY =     $00000001
COOKIE_CACHE_ENTRY =     $00100000
URLHISTORY_CACHE_ENTRY = $00200000
TRACK_OFFLINE_CACHE_ENTRY = $00000010
TRACK_ONLINE_CACHE_ENTRY =  $00000020
STICKY_CACHE_ENTRY =    $00000004
SPARSE_CACHE_ENTRY =    $00010000
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 9844742
Look like you have no vcl source code version ( similar with Personal in new D versions ). You don't have database vcl, right ?
0
 
LVL 1

Expert Comment

by:dyancer
ID: 9849734
hey

you can try this site, it has a complete delphi code and demo for handling MS Internet Browser.
http://www.euromind.com/iedelphi/index.htm
this will let u delete the history...
http://www.euromind.com/iedelphi/urlhistory.htm

and here u will find alot of usefull functions for controlling the browser configuration.
http://www.euromind.com/iedelphi/ie5tools.htm

much more things inside,

good luck
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 9858952
dyancer, maybe is well to read the question first ;P

>>I use Delphi 3. There is a component (http://www.euromind.com/iedelphi/) but this is for Delphi 4, 5, 6.
0
 

Author Comment

by:rincewind666
ID: 9860802
No source code...
0
 

Author Comment

by:rincewind666
ID: 10034542
Still can't get it to work. However I am splitting the points for attempted help as this seems fair.  Maybe it will work in some other version of Delphi?  Thanks anyway.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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