BSTR and a LPOLESTR

C

Chris

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.
 
U

Unforgiven

Chris said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

bstr and delete[] 12
Convert SYSTEMTIME to BSTR 2
bstr string to New character string 5
BSTR 0
BSTR 0
Retrieving BSTR * from a DLL 2
Simple compilation? 5
How to Interop 2D char in c# 0

Members online

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top