?
Solved

Deleting browser history etc using Delphi 3

Posted on 2003-11-22
15
Medium Priority
?
569 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
[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
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 9

Assisted Solution

by:ginsonic
ginsonic earned 800 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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