Solved

Deleting browser history etc using Delphi 3

Posted on 2003-11-22
15
545 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

13 Experts available now in Live!

Get 1:1 Help Now