请问在Delphi中怎样搜索IE缓存的mp3文件(100分)

  • 主题发起人 主题发起人 网络3K
  • 开始时间 开始时间

网络3K

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在Delphi中怎样搜索IE缓存的mp3文件,谢谢!
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinINet;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
Stop:boolean;
Procedure AddInfo(lpEntryInfo: PInternetCacheEntryInfo;id:integer);
public
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AddInfo(lpEntryInfo: PInternetCacheEntryInfo;
id: integer);
begin

if SameText(ExtractFileExt(lpEntryInfo^.lpszLocalFileName), '.mp3') then

ListBox1.Items.Append(lpEntryInfo^.lpszLocalFileName);
end;


procedure TForm1.Button1Click(Sender: TObject);
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord ;
dwEntrySize, dwLastError: LongWord;
id:integer;
begin

Stop:=false;
id:=0;

dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);

GetMem(lpEntryInfo, dwEntrySize);

hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then

AddInfo(lpEntryInfo,id);
id:=id+1;
FreeMem(lpEntryInfo);

repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
dwLastError := GetLastError();
if dwLastError = ERROR_INSUFFICIENT_BUFFER then

begin

GetMem(lpEntryInfo, dwEntrySize);
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then

begin

AddInfo(lpEntryInfo,id);
id:=id+1;
end;

FreeMem(lpEntryInfo);
end;

application.ProcessMessages;
until (dwLastError = ERROR_NO_MORE_ITEMS) or Stop ;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

Stop:=true;
end;


end.

 
后退
顶部