Board index » cppbuilder » Why BSTR but not WideString?

Why BSTR but not WideString?


2003-06-29 11:30:26 AM
cppbuilder20
I am learning to write COM object and want to create property of String
type, and of course there is no such an AnsiString or WideString in COM,so i
create property of BSTR and think that when importing my COM dll, cbuilder
will automatically create a wrapper class and convert the BSTR type to
WideString. But it didn't.
However,i do find some WideString property in the ActiveX Control i have
ever imported and used, eg. Windows Media Player 1.0 control. In the wrapper
class of it ,all the string property are of type WideString rather than
BSTR. So i wonder that how it made it?
Thanks in advance.
Regards,
Booker
 
 

Re:Why BSTR but not WideString?

And if i import the same COM dll to delphi,all BSTR are converted into
WideString, Why BCB do not.
"booker" < XXXX@XXXXX.COM >дÈëÓʼþ
Quote
I am learning to write COM object and want to create property of
String
type, and of course there is no such an AnsiString or WideString in COM,so
i
create property of BSTR and think that when importing my COM dll, cbuilder
will automatically create a wrapper class and convert the BSTR type to
WideString. But it didn't.

However,i do find some WideString property in the ActiveX Control i
have
ever imported and used, eg. Windows Media Player 1.0 control. In the
wrapper
class of it ,all the string property are of type WideString rather than
BSTR. So i wonder that how it made it?

Thanks in advance.

Regards,
Booker


 

Re:Why BSTR but not WideString?

"booker" < XXXX@XXXXX.COM >wrote in message
Quote
I am learning to write COM object and want to create
property of String type, and of course there is no such an
AnsiString or WideString in COM
Correct. BSTR is the official data type for COM strings.
Quote
so i create property of BSTR and think that when importing
my COM dll, cbuilder will automatically create a wrapper
class and convert the BSTR type to WideString. But it didn't.
No, it will not automatically convert it for you. It will generate a VCL
wrapper class that includes a __property for the value, but the data type
will remain BSTR. It will not be converted automatically. Nor should it
be.
Quote
However,i do find some WideString property in the
ActiveX Control i have ever imported and used, eg.
Windows Media Player 1.0 control.
Please outline the exact steps you took to produce that. Because I have
been using BCB for 5 years now and have never seen it do what you are
claiming.
Quote
In the wrapper class of it ,all the string property are of
type WideString rather than BSTR.
What does the original COM object declarations look like exactly, and what
does the generated wrapper class look like exactly?
Gambit
 

{smallsort}

Re:Why BSTR but not WideString?

Quote
What does the original COM object declarations look like exactly, and what
does the generated wrapper class look like exactly?
You can find it out after you imported one.