function SendFile:Boolean;
var output:
String;
begin
output:=CaptureConsoleOutput(Command);
Result:=Pos('
100%',output)>0;
end;
//Diese Funktion hab ich mal irgendwo gefunden (hier in der DP ?)
function CaptureConsoleOutput(
const ACommand:
String):
String;
const
CReadBuffer = 2400;
var
saSecurity: TSecurityAttributes;
hRead: THandle;
hWrite: THandle;
suiStartup: TStartupInfo;
piProcess: TProcessInformation;
pBuffer:
array [0 .. CReadBuffer]
of AnsiChar;
dBuffer:
array [0 .. CReadBuffer]
of AnsiChar;
dRead: DWord;
dRunning: DWord;
erg:
String;
begin
saSecurity.nLength := SizeOf(TSecurityAttributes);
saSecurity.bInheritHandle := True;
saSecurity.lpSecurityDescriptor :=
nil;
erg:='
';
if CreatePipe(hRead, hWrite, @saSecurity, 0)
then
begin
FillChar(suiStartup, SizeOf(TStartupInfo), #0);
suiStartup.cb := SizeOf(TStartupInfo);
suiStartup.hStdInput := hRead;
suiStartup.hStdOutput := hWrite;
suiStartup.hStdError := hWrite;
suiStartup.dwFlags := STARTF_USESTDHANDLES
or STARTF_USESHOWWINDOW;
suiStartup.wShowWindow := SW_HIDE;
if CreateProcess(
nil, pChar(ACommand+'
'), @saSecurity, @saSecurity, True, NORMAL_PRIORITY_CLASS,
nil,
nil, suiStartup, piProcess)
then
begin
//repeat
dRunning := WaitForSingleObject(piProcess.hProcess, 2000);
Application.ProcessMessages();
repeat
dRead := 0;
ReadFile(hRead, pBuffer[0], CReadBuffer, dRead,
nil);
pBuffer[dRead] := #0;
OemToCharA(pBuffer, dBuffer);
erg:=dBuffer;
until (dRead < CReadBuffer);
//until (dRunning <> WAIT_TIMEOUT);
CloseHandle(piProcess.hProcess);
CloseHandle(piProcess.hThread);
end;
CloseHandle(hRead);
CloseHandle(hWrite);
end;
Result:=erg;
end;
function Command:
String;
var path:
String;
begin
//hier lag die PSCP.exe mit im Programm-Verzeichnis, daher:
path:=ExtractFilePath(Application.ExeName);
Result:=path+'
pscp.exe -P '+Port+'
-pw '+pswrd+'
'+
Dateienname+'
'+username+'
@'+
URL+'
:'+targetdir;
//alt mit keyfile im Programm-Verzeichnis:
//Result:=path+'pscp.exe -P '+Port+' -i '+path+keyfile+' '+
// Dateiename+' '+username+'@'+URL+':'+targetdir;
end;