Hi Mike
For some reason I had version 5. The help file for that version did not contain any documentation for the Secure Shell Protocol, nor was there a CSTSHAV5.DLL present.
I have now replaced it with version 6, and done as you suggested, but I now have another problem with the connect. The VMS machine I wish to connect to doesn't have a password set for any of the logins we use. If I send NULL or "" as the password parameter, all I get is "The specified password is invalid". I also attempted to tell it that no password was required using CreateSecurityCredentials. This call returned success but it still refused to connect, with the same error message. This is the code I wrote. All I want to do is establish a connection, and verify that the characters for the initial screen are received on the connection:
(Calling exe- Borland CBuilder 6)
- Code: Select all
#define __CALL_TYPE __declspec(dllimport) WINAPI
extern int __CALL_TYPE SshRead(char *szBuffer, UINT uiSize);
extern void __CALL_TYPE SshDisconnect();
extern int __CALL_TYPE SshConn(char *szHost, char *szUsername, char *szPassword);
...
// Can't call it SshConnect as this results in a linker error
if (SshConn(szHost, szUsername, szPassword))
{
do
{
uiSize = SshRead(szBuffer, 256);
if (uiSize > 0)
{
szBuffer[uiSize] = 0;
sprintf(szMessage, "(%d) %s", uiSize, szBuffer);
MessageBox(NULL, szMessage, "Data Read", MB_OK);
}
} while (uiSize > 0);
SshDisconnect();
}
else
{
MessageBox(NULL, "Failed to connect", "Error", MB_ICONERROR);
}
(called DLL - Borland CBuilder 6)
#define __CALL_TYPE __declspec(dllexport) WINAPI
extern "C" {
int __CALL_TYPE SshConn(char *szHost, char *szUsername, char *szPassword);
int __CALL_TYPE SshRead(char *szBuffer, UINT uiSize);
void __CALL_TYPE SshDisconnect();
}
...
int __CALL_TYPE SshConn(char *szHost, char *szUsername, char *szPassword)
{
BOOL bResult;
BOOL bPasswordRequired = TRUE;
if (!strcmp(szPassword, ""))
{
// No password required
BOOL bResult;
bResult = m_sshClient.CreateSecurityCredentials((const char *)NULL, (const char *)NULL);
if (!bResult)
{
MessageBox(NULL, "CreateSecurityCredentials failed", "Error", MB_ICONWARNING);
return bResult;
}
bPasswordRequired = FALSE;
}
if (bPasswordRequired)
{
bResult = m_sshClient.Connect(
szHost,
0,
szUsername,
szPassword);
}
else
{
bResult = m_sshClient.Connect(
szHost,
0,
szUsername,
(char *) NULL);
}
if (!bResult)
{
m_sshClient.ShowError();
}
else
{
MessageBox(NULL, "Connected", "Info", MB_OK);
m_bConnected = TRUE;
}
return bResult;
}
Brian