Solved

Deleting browser history etc using Delphi 3

Posted on 2003-11-22
15
549 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wininet read php file from internet issue 6 81
Virtuailstring tree compare node issue 14 104
Delphi - replicating a form 8 62
tidtcpserver connection lost handle 2 70
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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now