Compartilhar via


PREfast Warning 307 (Windows CE 5.0)

Send Feedback

307 - Cast between semantically different string types.
Additional Information: wchar * to BSTR.

The memory layout and management of wchar * and BSTR are different.

If the function attempts to find the length of the BSTR, free it, or pass it to another function or Win32 API that is expecting a BSTR, this call can cause an access violation.

Example

Defective Source

LPWSTR pSrc = L"Hi";

MyFunction(pSrc); 

Corrected Source

LPWSTR pSrc = L"Hi";
BSTR bSrc = SysAllocString(pSrc);
MyFunction(bSrc); 

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.