BSTR datatype?

Posted by Admin on 16-Sep-2011 11:52

I'm working with an OCX that requires passing a pointer to a BSTR data type:

WORD mess[4] = {0x1,0x3,0x40,0x0};
BSTR pStringMessage = ::SysAllocString(mess);
Control.DirectIO(0,0,&pStringMessage);

I have tried various combinations of data types (char array, int array, memptr, etc) but I get "type mismatch" from the control. 
For memptr, i am not sure how to construct BSTR.  Any ideas / guidance is appreciated!
Thanks!

All Replies

Posted by jmls on 18-Oct-2011 12:48

what version of Progress ?

Posted by Admin on 18-Oct-2011 13:06

10.2B

I was told that BSTR has something to do with putting the length to follow in the first two bytes, so I tried this...

        DEFINE VARIABLE mpData     AS MEMPTR.

        SET-SIZE(mpData) = 17.

        PUT-SHORT(mpData,1) = 2.

        PUT-STRING(mpData,3) = "1".

        PUT-SHORT(mpData,5) = 2.

        PUT-STRING(mpData,7) = "3".

        PUT-SHORT(mpData,9) = 3.

        PUT-STRING(mpData,11) = "20".

        PUT-SHORT(mpData,14) = 2.

        PUT-STRING(mpData,16) = "0".

But it still doesn't work.  I'm not sure if I have the byte offsets correct, or if this is the right approach at all.
Thanks for any idea!

Posted by jmls on 18-Oct-2011 13:32

Hmm. http://msdn.microsoft.com/en-us/library/ms221069(v=vs.85).aspx

says that the first 4 bytes are the length ...

Posted by Admin on 18-Oct-2011 14:09

http://www.youtube.com/watch?v=ZCFCeJTEzNU

Many thanks!  This is exactly what I needed!  (Don't ask why I couldn't find this...)

Cheers,

Steve

This thread is closed