Use with Delphi

Advertisement

ordromike
Joined:
Posts:
2

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 ?

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:
8
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:
http://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)

Reply with quote

Advertisement

Gerhard_S
Joined:
Posts:
8
Location:
Berlin, Germany

Using Delphi

You can find a free sample application (including source code), written with Delphi XE, on my website:
https://www.seyso.de/projects_e/projects_en.php
It demonstrates the use of the cd, ls, put, get, and synchronize commands as well as evaluating the xml logfile.
It is not meant for commercial use, as it does not encrypt password nor user name.
Please send remarks to me using the contact form on
https://www.seyso.de/varia_e/contact_e/contact_en.php

Reply with quote

Advertisement

You can post new topics in this forum