Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Gerhard_S

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 sesssion 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:
1. List the content of the remote directory to a stringlist (so it becomes possible to prevent overwriting of existing files)
2. get an online error message (not only in the logfile)
ordromike

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.
martin

Re: Use with Delphi

Please read documentation. If that does not help, come back.
ordromike

Use with Delphi

Hello.

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