От полной тоски слепил библиотеку используя 9 инди. Все работает, но конечно бред....
| Код | library Project2;
{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP;
var idftp1:Tidftp; bytestosend:integer;
{$R *.res}
procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); stdcall; begin bytestosend:=AWorkCountMax; end;
procedure Init; stdcall; begin idftp1:=Tidftp.Create(Application); // idftp1.OnWorkBegin:=IdFTP1WorkBegin; //ошибка end;
function SetProxyParams(host,user,pass:string;port:integer):boolean; stdcall; begin result:=false; try IdFTP1.ProxySettings.Host:=host; IdFTP1.ProxySettings.Port:=port; IdFTP1.ProxySettings.UserName:=user; IdFTP1.ProxySettings.Password:=pass; finally result:=true; end; end;
function ConnectToFTP(host,user,pass:string;port:integer;passive:boolean):boolean; stdcall; begin result:=false; try If IdFTP1.Connected then IdFTP1.Disconnect; idftp1.Host:=host; idftp1.Username:=user; idftp1.Password:=pass; IdFTP1.Passive:=passive; IdFTP1.Port:=port; IdFTP1.Connect; //Соединяемся If IdFTP1.Connected then result:=true; except result:=false; end; end;
function ChangeDir(s:string):boolean; stdcall; begin result:=false; try IdFTP1.ChangeDir(s); finally result:=true; end; end;
function ChangeDirUp:boolean; stdcall; begin result:=false; try IdFTP1.ChangeDirUp; finally result:=true; end; end;
function FileExist(s:string):boolean; stdcall; var fold:TStringList; begin result:=false; try fold:=TStringList.Create; IdFTP1.List(fold,'',false); if fold.IndexOf(s)<>-1 then result:=true; finally fold.free; end; end;
function MakeDir(s:string):boolean; stdcall; begin result:=false; try IdFTP1.MakeDir(s); finally result:=true; end; end;
function Put(filename,destfilename:string; resume:boolean):boolean; stdcall; begin result:=false; try IdFTP1.Put(filename, destfilename,resume);
finally result:=true; end; end;
procedure DisconnectFromFTP; stdcall; begin IdFTP1.Disconnect; IdFTP1.Quit; IdFTP1.Free; end;
exports Init, FileExist, ConnectToFTP, ChangeDir,ChangeDirUp, Put, MakeDir, DisconnectFromFTP, SetProxyParams; begin end.
|
единственное не получается прицепить OnWorkBegin, чтобы получать кол-во байт |