Passing Strings to COM/ActiveX in C++ Builder
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:
long lSuccess; 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... long lSuccess; spChilkatMHT->UnlockComponent (L"UnlockCode", &lSuccess);