Admin Production ni-theme
Current Publication

CA_BSTRGetCStringBuf

LabWindows/CVI

CA_BSTRGetCStringBuf

HRESULT CA_BSTRGetCStringBuf (BSTR BSTR, char cStringBuffer[], size_t bufferSize);

Purpose

Converts a BSTR into a C-style string and copies it into a buffer you pass as a parameter. A BSTR is a Basic-style string that stores both text and length information.

CA_BSTRGetCStringBuf does not free the BSTR.

If buffer is not large enough to hold the string, CA_BSTRGetCStringBuf copies (bufferSize — 1) bytes to the buffer, followed by an ASCII NUL byte.

Parameters

Input
Name Type Description
BSTR BSTR BSTR you want to convert to a C-style string.
bufferSize size_t Number of bytes in buffer. Must be must be large enough to hold the string text and an ASCII NUL byte.
Output
Name Type Description
cStringBuffer char [] Character buffer into which CA_BSTRGetCString copies the C-style string it converts from the BSTR.

Return Value

Name Type Description
result HRESULT >=0 Number of bytes in the C-style string.

<0 Error code.

Refer to <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h for Windows SDK error codes.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later