Topic "Example winScp.dll"

Author Message
cyber_morfeo
[View user's profile]

Joined: 04 Feb 2004
Posts: 2
Hi, I want send a file from my Form Aplication (in c++ builder) , using winscp.dll. Do you have some example Question

Thanks Surprised
Advertisements
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
You probably mean winscp.dll from WinSCP plugin for FAR. The DLL relies on FAR manager environment, so cannot use it unless you "emulate" FAR envorinment. This would be too difficult I guess. If you have C++Builder 6, you may use the source code of WinSCP. You need just ScpCode.lib library (core subdirectory).

BTW, I'm going to delete your other 6 duplicate posts.
_________________
Martin Prikryl
Guest




prikryl wrote:
You probably mean winscp.dll from WinSCP plugin for FAR. The DLL relies on FAR manager environment, so cannot use it unless you "emulate" FAR envorinment. This would be too difficult I guess. If you have C++Builder 6, you may use the source code of WinSCP. You need just ScpCode.lib library (core subdirectory).

BTW, I'm going to delete your other 6 duplicate posts.


Hi!, Thanks for the help, Now I Understand this:

TTerminal *Terminal = new TTerminal();
TSCPFileSystem *SCP;
TStrings *FilesToCopy = new TStringList();
TCopyParamType *CopyParam = new TCopyParamType();
TFileOperationProgressType *OperationProgress = new TFileOperationProgressType();
bool DisconnectWhenComplete = true;

Terminal->SessionData->PortNumber = 22;
Terminal->SessionData->HostName = "192.168.21.40";
Terminal->SessionData->UserName = "fvelez";
Terminal->SessionData->Password = "cyber_morfeo";
Terminal->Open();
if (Terminal->Status != sshClosed){
SCP = new TSCPFileSystem(Terminal);
FilesToCopy->Add("c:\prueba.txt");
CopyParam->TransferMode = tmBinary;
SCP->CopyToRemote(FilesToCopy,"/home/fvelez", CopyParam, 2,
OperationProgress, &DisconnectWhenComplete);
delete(SCP);
Terminal->Close();
}
delete(Terminal);

That's OK? my aplication include putty.lib, scpcore.lib and SCPFileSystem.cpp, but send the next messages:

Unresolved external '_fastcall ShowExtendedException(Sysutils::Exception *, System::TObject *)'
Unresolved external '_fastcall GetRegistryKey()'
Unresolved external '_fastcall GetSessionPassword(System::AnsiString, TPasswordKing *,System::AnsiString &)
Unresolved external '_fastcall SshVersionString()'
Unresolved external '_fastcall HandleExtendedException(System::Exception *, System::TObject *)'
Unresolved external '_fastcall Busy(bool)'

Some Idea?

Thanks!
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
Some hints:
- Do not create instance of TFileSystem by yourself. TTerminal creates its own. Call methods of TTerminal only. To specify SCP transfer mode, use:
SessionData->FSProtocol = fsSCPonly
- Unresolved externals: you need to implement these functions in your application. See for example:
windows\WinInterface.cpp
windows\UserInterface.cpp
or
far\FarInterface.cpp
_________________
Martin Prikryl
Guest




prikryl wrote:
Some hints:
- Do not create instance of TFileSystem by yourself. TTerminal creates its own. Call methods of TTerminal only. To specify SCP transfer mode, use:
SessionData->FSProtocol = fsSCPonly
- Unresolved externals: you need to implement these functions in your application. See for example:
windows\WinInterface.cpp
windows\UserInterface.cpp
or
far\FarInterface.cpp


Ok!, the next source is comiled succesfully!

TTerminal *Terminal;
TStrings *FilesToCopy = new TStringList();
TCopyParamType *CopyParam = new TCopyParamType();

Terminal = new TTerminal();
Terminal->SessionData->FSProtocol = fsSCPonly;
Terminal->SessionData->PortNumber = 22;
Terminal->SessionData->HostName = "192.168.21.40";
Terminal->SessionData->UserName = "fvelez";
Terminal->SessionData->Password = "cyber_morfeo";
/* Configuration is declared as TConfiguration Configuration
in header file*/
Configuration = new TConfiguration();
Configuration->Default();
Configuration->Load();
Terminal->Open();
if (Terminal->Status != sshClosed){
FilesToCopy->Add("c:\prueba.txt");
CopyParam->TransferMode = tmBinary;
Terminal->CopyToRemote(FilesToCopy,"/home/fvelez", CopyParam,2);
Terminal->Close();
}
delete(Terminal);
delete(Configuration);

But, SshVersionString function (called from Terminal->Open()), show the next error: "Acces violation at address 77BD11C7. Read of Address 00000004" Sad
In the options of my proyect is included the "Version info" and next conditionals:

OLD_DND;
_FAR_USE_FARFINDDATA;
USE_COMPATIBLE_THREAD;
PUTTY_LIB;
_WINDOWS;
_MSC_VER=1000

any Idea is good!

Thanks!
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
Anonymous wrote:
/* Configuration is declared as TConfiguration Configuration
in header file*/
Configuration = new TConfiguration();
Configuration->Default();
Configuration->Load();

You should here assign Configuration to Terminal:
Terminal->Configuration = Configuration;

If you want to have feedback about transfer progress, you should also assign events Terminal->OnProgress and Terminal->OnFinished.

Quote:
Terminal->CopyToRemote(FilesToCopy,"/home/fvelez", CopyParam,2);

There is no Param 2. Use these constants (from Terminal.h):
const cpDelete = 0x01;
const cpDragDrop = 0x04;
const cpTemporary = 0x04; // alias to cpDragDrop
const cpNoConfirmation = 0x08;

You should at least use cpNoConfirmation, otherwise you need to implement event Terminal->OnQueryUser. You maybe need to implement it anyway, because the default answer is "cancel", which applies among other to "overwrite confirmation"

Quote:
But, SshVersionString function (called from Terminal->Open()), show the next error: "Acces violation at address 77BD11C7. Read of Address 00000004" Sad

It is hard to tell why it fails. The easiest thing to do is to implement SshVersionString() to return constant string.

Quote:
In the options of my proyect is included the "Version info" and next conditionals:

OLD_DND;
_FAR_USE_FARFINDDATA;
USE_COMPATIBLE_THREAD;
PUTTY_LIB;
_WINDOWS;
_MSC_VER=1000

Remove _FAR_USE_FARFINDDATA, _MSC_VER and _WINDOWS. There are conditionals necessary for FAR plugin API. You do not use it.

I hope this helps.
_________________
Martin Prikryl
Guest




Thanks for your help!, but now show next Exception Crying or Very sad :

"Accertion failed: FTerminal->FFiles && FTerminal->FFiles->Loaded: in file ScpFileSystem.cpp, en line 1158"

on method "TSCPFileSystem::CopyToRemote".

is necesary the Terminal->DoStartup() method, after of Terminal->Open() ?? Question

thanks (again)!
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
Quote:
"Accertion failed: FTerminal->FFiles && FTerminal->FFiles->Loaded: in file ScpFileSystem.cpp, en line 1158"

on method "TSCPFileSystem::CopyToRemote".

is necesary the Terminal->DoStartup() method, after of Terminal->Open() ?? Question

Yes you should call DoStartup().
_________________
Martin Prikryl
Guest




Hi!, I Can't run DoStartup() method, show Exception ""! in the next line:

File->ListingStr = OutputCopy->Strings[Index]

where OutputCopy->Strings[Index] = "lrwxrwxrwx 1 fvelez matiu 36 Jan 2 2003 .DCOPserver_huauhtli -> /home/fvelez/.DCOPserver_huauhtli_:0" and Index = 2

This is call in:
TTerminal::DoStartup()
- TTerminal::EndTransaction()
- TTerminal::ReadDirectory()
- TTerminal::CustomReadDirectory
- TTerminal::TSCPFileSystem::ReadDirectory()

I need any response fast!

Other promblem finding was I try conect to Remote Server in other city, but not was posible and with PSCP.exe is succesfull!

wath is the diference with PSCP?

Thanks!
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
Anonymous wrote:
Hi!, I Can't run DoStartup() method, show Exception ""! in the next line:

File->ListingStr = OutputCopy->Strings[Index]

where OutputCopy->Strings[Index] = "lrwxrwxrwx 1 fvelez matiu 36 Jan 2 2003 .DCOPserver_huauhtli -> /home/fvelez/.DCOPserver_huauhtli_:0" and Index = 2

You have reversed month and day in your listing. WinSCP does not support this.

Quote:
Other promblem finding was I try conect to Remote Server in other city, but not was posible and with PSCP.exe is succesfull!

wath is the diference with PSCP?

Need more info. Also try to read requirements and transfer protocols pages before asking. Thanks.
_________________
Martin Prikryl
cyber_morfeo
[View user's profile]

Joined: 04 Feb 2004
Posts: 2
prikryl wrote:

You have reversed month and day in your listing. WinSCP does not support this.


I work with protocol fsSFTP ( without DoStartup method Question) and send my file correctly Laughing

Some other idea with the problem of SCP protocol?

prikryl wrote:
Need more info. Also try to read requirements and transfer protocols pages before asking. Thanks.


Embarassed Sorry I discovery wath WinSCP is more powered what PSCP, the problem was the Server version (only with SCP)

Thanks for your help and congratulation for your good work ! Smile
prikryl
[View user's profile]
Site Admin
Joined: 10 Dec 2002
Posts: 19344
Location: Prague, Czech republic
cyber_morfeo wrote:
prikryl wrote:

You have reversed month and day in your listing. WinSCP does not support this.


I work with protocol fsSFTP ( without DoStartup method Question) and send my file correctly Laughing

You must call DoStartup. It strange that it work without. If it does that it is violation of SFTP protocol from the servers side. In DoStartup() client and server agrees on SFTP version to use. When you do not call it that probably (I have never tried), WinSCP assumes version 0. And I have never debugged WinSCP against SFTP version 0, because I do not have any server that knows version 0. You've been warned Smile

With SFTP the problem you have with SCP (see below) should not occur.

Quote:
Some other idea with the problem of SCP protocol?

Still the same: "You have reversed month and day in your listing. WinSCP does not support this." The next version will.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License