Use with Delphi

Advertisement

ordromike
Joined:
Posts:
2

Use with Delphi

Hello.

I would like use WinSCP process with Delphi language.
There is examples in .NET (C# and VB) on this site.
Have you an example in Delphi?

Reply with quote

Advertisement

ordromike
Joined:
Posts:
2

In Delphi, I use CreateProcess() for create a process with WinSCP.com.
After, I would like "send" function open, put, close...

But I don't know what functions to use for this (like WriteLine() in example C# and VB.NET in documentation)

And I cant find informations!

Can you help me?
Thanks.

Reply with quote

Gerhard_S
Joined:
Posts:
7
Location:
Berlin, Germany

Hi,
I got an elementary part of WinSCP to work with Delphi XE.
To call WinSCP, I use the function ShellExecute_AndWait, which can be found at Torry or here:
https://www.swissdelphicenter.ch/en/showcode.php?id=93
Password, host name and session information is stored in WinSCP.ini - before using Delphi, I established a connection via the WinSCP GUI and saved the session, including the password.
In Delphi, create a form with a button and a memo.
procedure TForm1.Button1Click(Sender: TObject);
var logdir, progdir, paramstring: string;
begin
  logdir := 'C:\Users\user\Documents';
  progdir := 'C:\Program Files (x86)\WinSCP\WinSCP.exe'; //for use with Win7/x64
  paramstring := '/ini=WinSCP.ini /log=logfile.txt /script=C:\Users\user\Documents\upload2.txt';
  if ShellExecute_AndWait('open', PChar(progdir), paramstring, logdir, SW_SHOWNORMAL, true) >=0 then
  begin
    Sleep(1000);
    Memo1.Lines.LoadFromFile(logdir + '\logfile.txt');
  end
  else
    ShowMessage('Error 1');
end;
The script file upload2.txt consists of:
option batch abort
option confirm off
open username@hostname.com
put D:\heuteneu.txt /httpdocs/content/test/heuteneu.txt
exit
Maybe someone can help me to solve the next tasks:
  • List the content of the remote directory to a stringlist (so it becomes possible to prevent overwriting of existing files)
  • get an online error message (not only in the logfile)

Reply with quote

Advertisement

You can post new topics in this forum