Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 26 Jan 2006 19:00:51 -0800,    group: microsoft.public.platformsdk.com_ole        back       


Passing Strings Around is BSTR still in fashion?   
What is the current best way to pass around a string?
I'm picking up COM and working from Essential COM, but it is quite dated 
and obliviously Microsoft Java isn't a platform to be concerned with 
about compatibility?  Is there a updated chart about IDL Types and 
various support for current languages floating around?
date: Thu, 26 Jan 2006 19:00:51 -0800   author:   Scott Markwell scott.markwell[a|t]gmail.com

Re: Passing Strings Around is BSTR still in fashion?   
Hi Scott,

> What is the current best way to pass around a string?
> I'm picking up COM and working from Essential COM, but it is quite
> dated
> and obliviously Microsoft Java isn't a platform to be concerned with
> about compatibility?  Is there a updated chart about IDL Types and
> various support for current languages floating around?

It depends.

BSTR is the only string type supported for automation clients (i.e. VBScript, 
JScript and to some extent VB), and it's definitely the type with best cross-language 
mapping.
If you only have C++ clients, you might as well go with straight OLE strings, 
i.e. wide-char C strings.

I haven't done any measurements, but the BSTR is length-prefixed, so for 
huge strings, it may be faster to get the length from a BSTR than from a 
C-style NUL-suffixed string, where the entire string has to be traversed 
to find the length.

Also, I know the BSTR allocator (SysAllocString and friends) has some heavy-duty 
caching in place, so it may be more efficient than CoTaskMemAlloc. Again, 
I haven't tried to measure this.

--
Best Regards,
Kim Grsman
date: Sat, 28 Jan 2006 10:08:35 +0000 (UTC)   author:   Kim Gräsman

Re: Passing Strings Around is BSTR still in fashion?   
Kim Grsman wrote:
> Hi Scott,
> 
>> What is the current best way to pass around a string?
>> I'm picking up COM and working from Essential COM, but it is quite
>> dated
>> and obliviously Microsoft Java isn't a platform to be concerned with
>> about compatibility?  Is there a updated chart about IDL Types and
>> various support for current languages floating around?
> 
> It depends.
> 
> BSTR is the only string type supported for automation clients (i.e. 
> VBScript, JScript and to some extent VB), and it's definitely the type 
> with best cross-language mapping.
> If you only have C++ clients, you might as well go with straight OLE 
> strings, i.e. wide-char C strings.
> 
> I haven't done any measurements, but the BSTR is length-prefixed, so for 
> huge strings, it may be faster to get the length from a BSTR than from a 
> C-style NUL-suffixed string, where the entire string has to be traversed 
> to find the length.
> 
> Also, I know the BSTR allocator (SysAllocString and friends) has some 
> heavy-duty caching in place, so it may be more efficient than 
> CoTaskMemAlloc. Again, I haven't tried to measure this.
> 
> -- 
> Best Regards,
> Kim Grsman
> 
> 

Thanks, one of the goals is provide access to the library from as many 
languages as possible.

-Scott Markwell
date: Tue, 31 Jan 2006 13:04:31 -0800   author:   Scott Markwell scott.markwell[a|t]gmail.com

Re: Passing Strings Around is BSTR still in fashion?   
> Thanks, one of the goals is provide access to the library from as many 
> languages as possible.

Then BSTR is your friend.

Brian
date: Tue, 31 Jan 2006 13:28:26 -0800   author:   Brian Muth

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us