---
name: "BSTR"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.0.1-3.1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/BSTR"
---

# BSTR(3w)

## NAME

**BSTR**

## NOTES

**BSTR** is a simple typedef for a wide-character string used as the principle string type in ole automation. When encapsulated in a Variant type they are automatically copied and destroyed as the variant is processed.

The low level **BSTR** Api allows manipulation of these strings and is used by higher level Api calls to manage the strings transparently to the caller.

Internally the **BSTR** type is allocated with space for a **DWORD** byte count before the string data begins. This is undocumented and non-system code should not access the count directly. Use **[SysStringLen(3w)](/SysStringLen/3w.md)** or **[SysStringByteLen(3w)](/SysStringByteLen/3w.md)** instead. Note that the byte count does not include the terminating **NUL**.

To create a new **BSTR**, use **[SysAllocString(3w)](/SysAllocString/3w.md)**, **[SysAllocStringLen(3w)](/SysAllocStringLen/3w.md)** or SysAllocStringByteLen(). To change the size of an existing **BSTR**, use **[SysReAllocString(3w)](/SysReAllocString/3w.md)** or **[SysReAllocStringLen(3w)](/SysReAllocStringLen/3w.md)**. Finally to destroy a string use **[SysFreeString(3w)](/SysFreeString/3w.md)**.

**BSTR**'s are cached by Ole Automation by default. To override this behaviour either set the environment variable 'OANOCACHE', or call **[SetOaNoCache(3w)](/SetOaNoCache/3w.md)**.

## SEE ALSO
