const
S_AGENT = '
YouAreSkored';
function UploadToFtp(serverName, userid, password, fileName:
string): LongBool;
var
hNet, hCon: HINTERNET;
begin
Result := False;
hNet := InternetOpen(S_AGENT, INTERNET_OPEN_TYPE_DIRECT,
nil,
nil, 0);
if Assigned(hNet)
then
begin
hCon := InternetConnect(hNet, PChar(servername),
INTERNET_DEFAULT_FTP_PORT, PChar(userid), PChar(password),
INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0
);
if Assigned(hCon)
then
begin
Result := FtpPutFile(hCon, PChar(fileName),
PChar(ExtractFileName(fileName)), FTP_TRANSFER_TYPE_ASCII, 0
);
InternetCloseHandle(hCon);
end else ShowMessage(SysErrorMessage(GetLastError));
InternetCloseHandle(hNet);
end else ShowMessage(SysErrorMessage(GetLastError));
end;
procedure TDemoForm.TestClick(Sender: TObject);
begin
if UploadToFtp('
localhost', '
achim', '
', ExtractFileName(ParamStr(0)))
then ShowMessage('
alli swell')
else ShowMessage(SysErrorMessage(GetLastError));
end;