Sign in to follow this  
Followers 0
sunless

help me with dllcall

1 post in this topic

I wan't find the url in IE cache . and I found func FindFirstUrlCacheEntryEx and FindNextUrlCacheEntryEx in wininet.dll can do it . So I wan't use Dllcall to use that func. but my script is worng.

my script

$d = DllStructCreate("dword;byte")
$t = DllStructCreate("dword;byte")
$m = DllStructCreate("dword;byte")
$tt = DllCall("wininet.dll","int","FindFirstUrlCacheEntryEx", _
                                    "str","", _ 
                                    "ptr", 0,  _ 
                                    "ptr","NORMAL_CACHE_ENTRY", _
                                    "ptr", 0, _
                                    "ptr", DllStructGetPtr($res), _
                                    "ptr",DllStructGetPtr($d), _
                                    "ptr", DllStructGetPtr($t), _
                                    "ptr", DllStructGetPtr($m), _
                                    "ptr",0)

and this is the func in msdn

HANDLE FindFirstUrlCacheEntryEx(

__in LPCTSTR lpszUrlSearchPattern,

__in DWORD dwFlags,

__in DWORD dwFilter,

__in GROUPID GroupId,

__out LPINTERNET_CACHE_ENTRY_INFO lpFirstCacheEntryInfo,

__inout LPDWORD lpdwEntryInfo,

__out LPVOID lpGroupAttributes,

__inout LPDWORD lpcbGroupAttributes,

__in LPVOID lpReserved

);

and msdn url http://msdn2.microsoft.com/en-us/library/a...034(VS.85).aspx

BOOL FindNextUrlCacheEntryEx(

__in HANDLE hEnumHandle,

__inout LPINTERNET_CACHE_ENTRY_INFO lpNextCacheEntryInfo,

__inout LPDWORD lpcbEntryInfo,

LPVOID lpGroupAttributes,

LPDWORD lpcbGroupAttributes,

LPVOID lpReserved

);

and http://msdn2.microsoft.com/en-us/library/a...057(VS.85).aspx

and a code of delphi

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    ListBox2: TListBox;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    function FindNextEntrys(Handle:Integer):Boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
function TForm1.FindNextEntrys(Handle:Integer):Boolean;
var
  T: PInternetCacheEntryInfo;
  D: DWORD;
begin
  D := 0;
  FindnextUrlCacheEntryEx(Handle, nil, @D, nil, nil, nil);
  GetMem(T, D);
  try
    if FindNextUrlCacheEntryEx(Handle, T, @D, nil, nil, nil) then begin
      ListBox1.Items.Add(T.lpszSourceUrlName);
      ListBox2.Items.Add(T.lpszLocalFileName);
      Result := True;
    end
    else
      Result := False;
  finally
    FreeMem(T, D)
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  H:Integer;
  T: PInternetCacheEntryInfo;
  D: DWORD;
begin
  D := 0;
  FindFirstUrlCacheEntryEx(nil, 0, NORMAL_CACHE_ENTRY, 0,nil,@D, nil, nil, nil);
  GetMem(T, D);
  try
    H := FindFirstUrlCacheEntryEx(nil,0, NORMAL_CACHE_ENTRY, 0, T, @D, nil, nil, nil);
    if (H = 0) then
    else begin
      repeat
      until not FindNextEntrys(H);
      FindCloseUrlCache(H);
    end
  finally
    FreeMem(T, D)
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  URL:String;
begin
  If ListBox1.ItemIndex >=0 then begin
    URL:=ListBox1.Items.Strings[ListBox1.ItemIndex];
    Self.Caption := URL;
    if DeleteUrlCacheEntry(PChar(URL))then
      ListBox1.Items.Delete(ListBox1.ItemIndex);
  end;
end;

end.

and type of PInternetCacheEntryInfo

PInternetCacheEntryInfoA = ^INTERNET_CACHE_ENTRY_INFOA;
  INTERNET_CACHE_ENTRY_INFOA = record
    dwStructSize: DWORD;         { version of cache system. ?? do we need this for all entries? }
    lpszSourceUrlName: PAnsiChar;   { embedded pointer to the URL name string. }
    lpszLocalFileName: PAnsiChar;   { embedded pointer to the local file name. }
    CacheEntryType: DWORD;     { cache type bit mask. }
    dwUseCount: DWORD;         { current users count of the cache entry. }
    dwHitRate: DWORD;           { num of times the cache entry was retrieved. }
    dwSizeLow: DWORD;           { low DWORD of the file size. }
    dwSizeHigh: DWORD;         { high DWORD of the file size. }
    LastModifiedTime: TFileTime; { last modified time of the file in GMT format. }
    ExpireTime: TFileTime;     { expire time of the file in GMT format }
    LastAccessTime: TFileTime;   { last accessed time in GMT format }
    LastSyncTime: TFileTime;     { last time the URL was synchronized }
                                 { with the source }
    lpHeaderInfo: PBYTE;         { embedded pointer to the header info. }
    dwHeaderInfoSize: DWORD;     { size of the above header. }
    lpszFileExtension: PAnsiChar;   { File extension used to retrive the urldata as a file. }
    dwReserved: DWORD;         { reserved for future use. }
  end;
  {$EXTERNALSYM INTERNET_CACHE_ENTRY_INFOA}
  PInternetCacheEntryInfoW = ^INTERNET_CACHE_ENTRY_INFOW;
  INTERNET_CACHE_ENTRY_INFOW = record
    dwStructSize: DWORD;         { version of cache system. ?? do we need this for all entries? }
    lpszSourceUrlName: PAnsiChar;   { embedded pointer to the URL name string. }
    lpszLocalFileName: PWideChar;   { embedded pointer to the local file name. }
    CacheEntryType: DWORD;     { cache type bit mask. }
    dwUseCount: DWORD;         { current users count of the cache entry. }
    dwHitRate: DWORD;           { num of times the cache entry was retrieved. }
    dwSizeLow: DWORD;           { low DWORD of the file size. }
    dwSizeHigh: DWORD;         { high DWORD of the file size. }
    LastModifiedTime: TFileTime; { last modified time of the file in GMT format. }
    ExpireTime: TFileTime;     { expire time of the file in GMT format }
    LastAccessTime: TFileTime;   { last accessed time in GMT format }
    LastSyncTime: TFileTime;     { last time the URL was synchronized }
                                 { with the source }
    lpHeaderInfo: PBYTE;         { embedded pointer to the header info. }
    dwHeaderInfoSize: DWORD;     { size of the above header. }
    lpszFileExtension: PWideChar;   { File extension used to retrive the urldata as a file. }
    dwReserved: DWORD;         { reserved for future use. }
  end;
  {$EXTERNALSYM INTERNET_CACHE_ENTRY_INFOW}
  PInternetCacheEntryInfo = PInternetCacheEntryInfoA;
  TInternetCacheEntryInfoA = INTERNET_CACHE_ENTRY_INFOA;
  LPINTERNET_CACHE_ENTRY_INFOA = PInternetCacheEntryInfoA;
  {$EXTERNALSYM LPINTERNET_CACHE_ENTRY_INFOA}
  TInternetCacheEntryInfoW = INTERNET_CACHE_ENTRY_INFOW;
  LPINTERNET_CACHE_ENTRY_INFOW = PInternetCacheEntryInfoW;
  {$EXTERNALSYM LPINTERNET_CACHE_ENTRY_INFOW}
  TInternetCacheEntryInfo = TInternetCacheEntryInfoA;

help me

thanks

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0