The Chilkat C++ libraries are now available for Embarcadero® C++ Builder®
For the downloads and more information, see: Chilkat for C++ Builder®
“C++Builder” is a registered trademark of Embarcadero Technologies.
“Embarcadero” is a registered trademark of Embarcadero Technologies.
In C++ Builder, when passing a string to an ActiveX (COM) function, a BSTR is required. This is different than a NULL-terminated WideString.
The correct syntax looks like this:
BSTR bstr = SysAllocString(L"UnlockCode");
spChilkatMHT->UnlockComponent (bstr, &lSuccess);
SysFreeString( bstr );
The following is incorrect because a NULL-terminated WideString is passed, and not a BSTR:
// This code will probably cause the program to crash...
spChilkatMHT->UnlockComponent (L"UnlockCode", &lSuccess);
The correct way to pass a string to a COM/ActiveX method is to use “WideString (theString).c_bstr()” because ActiveX controls/components require BSTR’s, and not strings. BSTR’s are wide strings (Unicode) where the length of the string precedes the string in memory.
The C++ Builder code to pass a string to an ActiveX function is as follows:
FClientSock = new TChilkatSocket(Owner);
success = FClientSock->UnlockComponent(WideString("30 day trial").c_bstr());