Several problems about storing binary data in BSTR

zhaozj2021-02-16  45

If the binary data contains two consecutive NULL characters,

Using a general allocation function sysallocstringBytelen will have a problem, it will cut off the data.

// error BYTE BUFFER [10] = "TEST / 0 / 0TEST"; BSTR BSTEMP; BSTEMP = SYSALLOCSTRINGBYTELEN (Buffer, 10);

The actual save content in BSTEMP has TEST

// Correct

BYTE BUFFER [10] = "TEST / 0 / 0TEST"; BSTR BSTEMP; BSTEMP = SYSALLOCSTRINGBYTELEN (NULL, 10); Memcpy (BSTEMP, BUFFER, 10);

In addition, when the BSTR data is transmitted with the component, the RAW method is used to call, and the _bstr_t package form cannot be used, otherwise the data is still packaged.

转载请注明原文地址:https://www.9cbs.com/read-27570.html

New Post(0)