Solved

Deleting browser history etc using Delphi 3

Posted on 2003-11-22
15
558 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 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
Independent Software Vendors: 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 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

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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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