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.