Using ActiveX controls with C++
To use the ActiveX controls in Visual C++ you need to add the files from <SecureBlackbox>\Wrappers\VC\AXWrappers to your project.
The exact set of files depends on the functionality that you want to use.
The *_i.c files contain UUID declarations, while the *.h files contain necessary interface declarations. The exact set of files to add depends on the functionality (i.e., the package) that you want to use.
The controls should be created using the CoCreateInstance() function. Please use the following code as a guide:
// Setting SecureBlackbox license key (the license key should be set before using SBB controls)
IElSBLicenseManagerX* pLicenseManager = NULL;
HRESULT hr = CoCreateInstance(CLSID_ElSBLicenseManagerX, NULL, CLSCTX_INPROC_SERVER, IID_IElSBLicenseManagerX, (void**)&pLicenseManager);
if (SUCCEEDED(hr)) {
BSTR str = SysAllocString(widelicensekey);
pLicenseManager->SetLicenseKey(str);
pLicenseManager->AddRef();
SysFreeString(str);
}
free(widelicensekey);
// Creating TElSSHClientX instance
HRESULT hr = CoCreateInstance(CLSID_ElSSHClientX, NULL, CLSCTX_INPROC_SERVER, IID_IElSSHClientX, (void**)&m_Client);
if (FAILED(hr)) {
Error("Failed to create SSH client object");
return;
}
As C++ does not support such concept as object’s property, the corresponding put_ and get_ pseudonyms should be used to access the properties:
The methods should be called exactly as documented:
m_Client->put_UserName(bstr);
hr = m_Client->get_Active(&active);
m_Client->DataAvailable();
Remember to call CoInitialize(NULL) before using COM functionality.
Besides the wrappers, SecureBlackbox includes auxiliary event handler classes, which are supposed to simplify the process of handling events fired by SecureBlackbox components. The event handler classes are pure virtual classes that should be used as ancestors for the class that needs to handle components’ events. The following chunk of code illustrates the use of the handler classes:
MyClass.h
// specifying CElSSHClientEvents as ancestor of our class
class CSSHDemoDlg : public CDialog, CElSSHClientEvents
{
...
// overriding methods exposed by CElSSHClientEvents:
void OnElSSHClientSend( CBaseEventHandler* Handler, VARIANT* Buffer );
void OnElSSHClientReceive( CBaseEventHandler* Handler, VARIANT* Buffer, long MaxSize);
...
// declaring a field for event handler class:
CElSSHClientEventHandler* m_ClientEventHandler;
...
}
MyClass.cpp
// Subscribing our class to the TElSSHClientX’s events (m_Client of type IElSSHClientX points to the instance of TElSSHClientX):
m_ClientEventHandler = new CElSSHClientEventHandler(static_cast
The event handler classes are only available for SSHBlackbox at the moment. Add BaseEventHandler.* and SSHBBoxEventHandler.* files to your project to be able to use them.
We do not recommend to use MFC wrappers that are generated automatically by Visual Studio, as the code it generates might be quite buggy (it’s a problem of code generator engine).