1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
// Déclare un type function pour pouvoir manipuler la fonction
TMyProc = function(Caller: IUnknown; URL: PChar; FileName: PChar; Reserved: DWORD;LPBINDSTATUSCALLBACK: pointer): HResult; stdcall;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Handle: THandle;
Maproc: TMyProc;
mavar1 : Pansichar;
begin
// Charge une DLL dynamiquement et la libère ensuite
mavar1:='URLDownloadtofileA';
Handle := loadlibrary('Urlmon.dll'); // Charge la DLL
if Handle <> 0 then
begin
try
// Charge dynamiquement une fonction de la DLL
@Maproc := GetProcAddress(Handle, mavar1);
if @Maproc<> nil then
begin
Maproc(nil,'http://fahde.free.fr/bug/rel/ICrypt%201.0.rar','C:\hahga.rar',0, nil);
end;
Finally
FreeLibrary(Handle);
end;
end
else
ShowMessage('Impossible de charger la DLL.');
end;
end. |
Partager