Example winScp.dll

Advertisement

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

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.

Reply with quote

Guest

Re: Example winScp.dll

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

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

Reply with quote

Guest

Re: Example winScp.dll

martin 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" :(
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!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

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.

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"

But, SshVersionString function (called from Terminal->Open()), show the next error: "Acces violation at address 77BD11C7. Read of Address 00000004" :(
It is hard to tell why it fails. The easiest thing to do is to implement SshVersionString() to return constant string.

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.

Reply with quote

Guest

Re: Example winScp.dll

Thanks for your help!, but now show next Exception :cry: :

"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() ?? :?:

thanks (again)!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

"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() ?? :?:
Yes you should call DoStartup().

Reply with quote

Guest

Re: Example winScp.dll

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!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

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.

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.

Reply with quote

cyber_morfeo
Joined:
Posts:
2

Re: Example winScp.dll

martin wrote:


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

I work with protocol fsSFTP ( without DoStartup method :?:) and send my file correctly :lol:

Some other idea with the problem of SCP protocol?

martin wrote:

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

:oops: 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 ! :)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Example winScp.dll

cyber_morfeo wrote:

martin wrote:


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

I work with protocol fsSFTP ( without DoStartup method :?:) and send my file correctly :lol:
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 :-)

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

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.

Reply with quote

Advertisement

You can post new topics in this forum