CodeGear C++ Builder: Passing Strings to COM / ActiveX Methods

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());
Tags :