BSTR Functions

The Wxutil.h header file in the Microsoft® DirectShow® base classes provides helper functions for allocating and freeing task-allocated BSTR strings.

FreeBSTR Frees the task-allocated BSTR string.
WriteBSTR Creates a task-allocated BSTR string by allocating task-allocated memory and copying a wide string to it.

FreeBSTR

BSTR Functions

Frees a task-allocated BSTR string from memory.

Syntax

STDAPI FreeBSTR(
    BSTR *pstr
    );

Parameters

pstr
Pointer to the BSTR to free.

Return Value

Returns S_OK if successful, or S_FALSE if pstr is null.

Remarks

Memory is allocated for passing between objects across interfaces by calling CoTaskMemAlloc. It is freed by calling CoTaskMemFree. You can allocate, pass, and free memory safely between objects created in different programming languages by using a central memory allocator.

WriteBSTR

BSTR Functions

Allocates and fills a task-allocated BSTR string.

Syntax

STDAPI WriteBSTR(
    BSTR *pstrDest,
    LPCWSTR szSrc
    );

Parameters

pstrDest
Pointer to where the allocated BSTR will be stored.
szSrc
Pointer to a wide (Unicode™) string that will be copied to the newly allocated BSTR string.

Return Value

Returns an HRESULT value.

Remarks

Memory is allocated for passing between objects across interfaces by calling CoTaskMemAlloc. It is freed by calling CoTaskMemFree. By using a central memory allocator, memory can be allocated, passed, and freed safely between objects created in different programming languages.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.