Witam mam programik w delphi do wysyłania tekstu przez ftp do pliku txt na serwerze
Używam komponentu wymagającego chillkatSSh.DLL
Więc program działa tylko wtedy gdy ktoś posiada tą biblioteke
a kodzik wysyłający wyglada tak
procedure TForm1.Button1Click(Sender: TObject);
var
handle: String;
begin
sftp := TChilkatSFtp.Create(Self);
success := sftp.UnlockComponent('SSH$TEAM$BEAN_472E62FD8UpX');
sftp.ConnectTimeoutMs := 5000;
sftp.IdleTimeoutMs := 15000;
hostname := 'ftp.klucha.linuxpl.eu';
port := 59184;
success := sftp.Connect(hostname,port);
success := sftp.AuthenticatePw('User','t1233');
success := sftp.InitializeSftp();
handle := sftp.OpenFile('klucha.txt','readWrite','openOrCreate');
success := sftp.WriteFileText(handle,'ansi','Linia'+#13+#10 );
success := sftp.CloseHandle(handle);
sftp.Disconnect();
showmessage ('ok');
end;
Postanowieniem połączyć tą bibliotekę z moim programem jako zasob RES/
Program przy starcie wypakowuje dll'a i ładuje go wykorzystując dynamicznie .
Jako że nie wiem jakie są funkcje i procedury ktoś mi podpowiedział aby wejsć w delphi projects->Import type library i wybrac chillkatSSH aby pokazało wszystkie procedury i funkcję.
i znalazłem tam np.
public
function Connect(const hostname: WideString; port: Integer): Integer;
oraz
function TChilkatSFtp.Connect(const hostname: WideString; port: Integer): Integer;
begin
Result := DefaultInterface.Connect(hostname, port);
end;
i teraz próbuje połączyć to w całość
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function Connect(const hostname: WideString; port: Integer): Integer;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
DLL : THandle; // uchwyt biblioteki
TChilkatSFtp.Connect : function ;
begin
DLL := LoadLibrary('c:\ChillkatSSh.dll'); // laduj biblioteke
try
@TChilkatSFtp.Connect := GetProcAddress(DLL, 'TChilkatSFtp.Connect'); // laduj procedure
if @TChilkatSFtp.Connect=nil then raise Exception.Create('Bład - nie mogę znaleźć proceudry w bibliotece!');
TChilkatSFtp.Connect; // wywolaj function
finally
FreeLibrary(DLL); // wreszcie zwolnij pamiec
end;
end;
function TChilkatSFtp.Connect(const hostname: WideString; port: Integer): Integer;
begin
Result := DefaultInterface.Connect(hosting.unl.pl, 21);
end;
end.
jak mam zrobić aby wykożystać tego dll aby połączyć się?
Cz w dobrym kierunku zmierzam?
to raport błędów
[Error] Unit1.pas(31): ',' or ':' expected but '.' found
[Error] Unit1.pas(31): Function needs result type
[Error] Unit1.pas(35): Missing operator or semicolon
[Error] Unit1.pas(36): Type of expression must be BOOLEAN
[Error] Unit1.pas(37): Missing operator or semicolon
[Error] Unit1.pas(43): Function needs result type
[Error] Unit1.pas(43): '=' expected but ';' found
[Error] Unit1.pas(43): '=' expected but ')' found
[Error] Unit1.pas(44): Missing operator or semicolon
[Error] Unit1.pas(45): Undeclared identifier: 'DefaultInterface'
[Error] Unit1.pas(45): Missing operator or semicolon
[Error] Unit1.pas(45): Missing operator or semicolon
[Error] Unit1.pas(17): Unsatisfied forward or external declaration: 'TForm1.Connect'
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'