function getfile(server, username, password, localfile, remotefile:
string; port: word = 21): Boolean;
var
hopen, hconnect: HINTERNET;
begin
hopen := InternetOpen('
myagent', INTERNET_OPEN_TYPE_DIRECT,
nil,
nil, 0);
if hopen <> 0
then begin
try
hconnect := InternetConnect(hopen, PChar(server), port, PChar(username), PChar(password), INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
if hconnect <> 0
then begin
try
Result := FtpGetFile(hconnect, pchar(localfile), pchar(remotefile), false, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0);
if not Result
then
RaiseLastOSError;
finally
InternetCloseHandle(hconnect);
end;
//end else
// RaiseLastOSError;
end else begin
// hier hatte ich noch InternetGetLastResponseInfo versucht ausgelesen, für eine Exception-Message
// InternetConnect: An application can also use InternetGetLastResponseInfo to determine why access to the service was denied.
end
finally
InternetCloseHandle(hopen);
end;
end else
RaiseLastOSError;
end;