By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

BSTR and a LPOLESTR

P: n/a
I am not sure if this is the right newsgroup. But does anyone know what is
the difference between a BSTR and a LPOLESTR?

The only thing I could find out is that the advantage of taking BSTR instead
of LPOLESTR is that determining the length of a BSTR is much faster.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Chris" <ch***@hotmail.net> wrote in message
news:Qe*******************@news-server.bigpond.net.au...
I am not sure if this is the right newsgroup. But does anyone know what is
the difference between a BSTR and a LPOLESTR?

The only thing I could find out is that the advantage of taking BSTR
instead of LPOLESTR is that determining the length of a BSTR is much
faster.


This isn't really the right group (try a microsoft.public.* group instead),
but:
Both LPOLESTR and BSTR are typedefs of 'unsigned short*'. A BSTR uses four
bytes before the pointer to indicate its size, and therefore needn't be zero
terminated. An LPOLESTR typically is zero terminated. A BSTR must always be
allocated using SysAllocString and freed using SysFreeString (at least if
you want to be interoperable with COM components)

The real difference is that LPOLESTR is a typedef used by OLE, and BSTR is a
typedef used by COM. If you interact with COM components, either by being a
COM component or by consuming one, you should use BSTR in combination with
SysAllocString/SysFreeString. BSTR is also the string type used by Visual
Basic 4, 5 and 6.

--
Unforgiven

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.