in reply to Re: calling a function from a dll
in thread calling a function from a dll

$value =~ s!\0.*!!; # we assume that the first \0 returned indicates end of the string

That is a pretty bad assumption. BSTRs are fixed length arrays of unsigned shorts with a prefix length and can contain multiple nulls.

See http://blogs.msdn.com/b/ericlippert/archive/2003/09/12/52976.aspx


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^3: calling a function from a dll
by nikosv (Deacon) on Jan 04, 2013 at 06:28 UTC

    what is interesting is that the prefix length is a byte count and not a character count,although BSTR is always Unicode

    So to find the end of the string you have to get to the stored length which is stored in the first 2 bytes

    the example at : BSTR layout shows the byte count and the terminated nulls,both required by BSTR