Strings in Automation ATL/COM/OLE


I am still trying to get help with my orignal question so....

In automations where the doc says string as in the case WorkBooks::OpenText

1) the string is formated as VT_BSTR

when I look in memory at my file name there is 1 by of X'00' between every character

C X'00' : X'00' \ X'00' etc etc
This is the correct format of VT_BSTR
Who is Participating?
ZoppoConnect With a Mentor Commented:
Yes, that's exactly what I wrote above. What you see as NULL byte between each character is simply a UNICODE string where each character is a WCHAR which is a 16 byte value.

Please tell if you have further questions ...
Hm - what is the question?
JoereichmanAuthor Commented:
The filename first parameter is a string I believe LPCSTR this gets converted to a VT_BSTR

what is the format of a VT_BSTR string in automation
The VT_BSTR in fact is a VARTYPE which indicates a BSTR is used in an VARIANT.

OLE/Automation strings use BSTR which is described i.e. here:

In short: The BSTR first has a 4 bytes as length inidcator followed by UNICODE characters and two 0 (UNICODE-) characters as terminator.

Hope that helps,

JoereichmanAuthor Commented:
I have looked at the string Filename and it does fit a BSTR format 4 byte length with a null byte in between each character
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.