|
1 | 1 | --- |
2 | | -description: "Learn more about: _bstr_t Class" |
3 | | -title: "_bstr_t Class" |
4 | | -ms.date: "11/04/2016" |
| 2 | +title: "_bstr_t class" |
| 3 | +description: "Learn more about: _bstr_t class" |
| 4 | +ms.date: 02/02/2021 |
5 | 5 | f1_keywords: ["_bstr_t"] |
6 | 6 | helpviewer_keywords: ["BSTR object", "_bstr_t class", "BSTR object [C++], COM encapsulation"] |
7 | | -ms.assetid: 58841fef-fe21-4a84-aab9-780262b5201f |
8 | 7 | --- |
9 | | -# _bstr_t Class |
| 8 | +# `_bstr_t` class |
10 | 9 |
|
11 | 10 | **Microsoft Specific** |
12 | 11 |
|
13 | | -A `_bstr_t` object encapsulates the [BSTR data type](/previous-versions/windows/desktop/automat/bstr). The class manages resource allocation and deallocation through function calls to `SysAllocString` and `SysFreeString` and other `BSTR` APIs when appropriate. The **_bstr_t** class uses reference counting to avoid excessive overhead. |
| 12 | +A `_bstr_t` object encapsulates the [BSTR data type](/previous-versions/windows/desktop/automat/bstr). The class manages resource allocation and deallocation through function calls to [`SysAllocString`](/windows/win32/api/oleauto/nf-oleauto-sysallocstring) and [`SysFreeString`](/windows/win32/api/oleauto/nf-oleauto-sysfreestring) and other `BSTR` APIs when appropriate. The `_bstr_t` class uses reference counting to avoid excessive overhead. |
| 13 | + |
| 14 | +## Members |
14 | 15 |
|
15 | 16 | ### Construction |
16 | 17 |
|
17 | 18 | | Constructor | Description | |
18 | 19 | |--|--| |
19 | | -| [_bstr_t](../cpp/bstr-t-bstr-t.md) | Constructs a `_bstr_t` object. | |
| 20 | +| [`_bstr_t`](../cpp/bstr-t-bstr-t.md) | Constructs a `_bstr_t` object. | |
20 | 21 |
|
21 | 22 | ### Operations |
22 | 23 |
|
23 | 24 | | Function | Description | |
24 | 25 | |--|--| |
25 | | -| [Assign](../cpp/bstr-t-assign.md) | Copies a `BSTR` into the `BSTR` wrapped by a `_bstr_t`. | |
26 | | -| [Attach](../cpp/bstr-t-attach.md) | Links a `_bstr_t` wrapper to a `BSTR`. | |
27 | | -| [copy](../cpp/bstr-t-copy.md) | Constructs a copy of the encapsulated `BSTR`. | |
28 | | -| [Detach](../cpp/bstr-t-detach.md) | Returns the `BSTR` wrapped by a `_bstr_t` and detaches the `BSTR` from the `_bstr_t`. | |
29 | | -| [GetAddress](../cpp/bstr-t-getaddress.md) | Points to the `BSTR` wrapped by a `_bstr_t`. | |
30 | | -| [GetBSTR](../cpp/bstr-t-getbstr.md) | Points to the beginning of the `BSTR` wrapped by the `_bstr_t`. | |
31 | | -| [length](../cpp/bstr-t-length.md) | Returns the number of characters in the `_bstr_t`. | |
| 26 | +| [`Assign`](../cpp/bstr-t-assign.md) | Copies a `BSTR` into the `BSTR` wrapped by a `_bstr_t`. | |
| 27 | +| [`Attach`](../cpp/bstr-t-attach.md) | Links a `_bstr_t` wrapper to a `BSTR`. | |
| 28 | +| [`copy`](../cpp/bstr-t-copy.md) | Constructs a copy of the encapsulated `BSTR`. | |
| 29 | +| [`Detach`](../cpp/bstr-t-detach.md) | Returns the `BSTR` wrapped by a `_bstr_t` and detaches the `BSTR` from the `_bstr_t`. | |
| 30 | +| [`GetAddress`](../cpp/bstr-t-getaddress.md) | Points to the `BSTR` wrapped by a `_bstr_t`. | |
| 31 | +| [`GetBSTR`](../cpp/bstr-t-getbstr.md) | Points to the beginning of the `BSTR` wrapped by the `_bstr_t`. | |
| 32 | +| [`length`](../cpp/bstr-t-length.md) | Returns the number of characters in the `_bstr_t`. | |
32 | 33 |
|
33 | 34 | ### Operators |
34 | 35 |
|
35 | 36 | | Operator | Description | |
36 | 37 | |--|--| |
37 | | -| [operator =](../cpp/bstr-t-operator-equal.md) | Assigns a new value to an existing `_bstr_t` object. | |
38 | | -| [operator +=](../cpp/bstr-t-operator-add-equal-plus.md) | Appends characters to the end of the `_bstr_t` object. | |
39 | | -| [operator +](../cpp/bstr-t-operator-add-equal-plus.md) | Concatenates two strings. | |
40 | | -| [operator !](../cpp/bstr-t-operator-logical-not.md) | Checks if the encapsulated `BSTR` is a NULL string. | |
41 | | -| [operator ==, !=, \<, >, \<=, >=](../cpp/bstr-t-relational-operators.md) | Compares two `_bstr_t` objects. | |
42 | | -| [operator wchar_t* | char\*](../cpp/bstr-t-wchar-t-star-bstr-t-char-star.md) | Extract the pointers to the encapsulated Unicode or multibyte `BSTR` object. | |
| 38 | +| [`operator =`](../cpp/bstr-t-operator-equal.md) | Assigns a new value to an existing `_bstr_t` object. | |
| 39 | +| [`operator +=`](../cpp/bstr-t-operator-add-equal-plus.md) | Appends characters to the end of the `_bstr_t` object. | |
| 40 | +| [`operator +`](../cpp/bstr-t-operator-add-equal-plus.md) | Concatenates two strings. | |
| 41 | +| [`operator !`](../cpp/bstr-t-operator-logical-not.md) | Checks if the encapsulated `BSTR` is a NULL string. | |
| 42 | +| [`operator ==`](../cpp/bstr-t-relational-operators.md)<br/>[`operator !=`](../cpp/bstr-t-relational-operators.md)<br/>[`operator <`](../cpp/bstr-t-relational-operators.md)<br/>[`operator >`](../cpp/bstr-t-relational-operators.md)<br/>[`operator <=`](../cpp/bstr-t-relational-operators.md)<br/>[`operator >=`](../cpp/bstr-t-relational-operators.md) | Compares two `_bstr_t` objects. | |
| 43 | +| [`operator wchar_t*`](../cpp/bstr-t-wchar-t-star-bstr-t-char-star.md)<br/>[`operator char*`](../cpp/bstr-t-wchar-t-star-bstr-t-char-star.md) | Extract the pointers to the encapsulated Unicode or multibyte `BSTR` object. | |
43 | 44 |
|
44 | 45 | **END Microsoft Specific** |
45 | 46 |
|
46 | 47 | ## Requirements |
47 | 48 |
|
48 | 49 | **Header:** \<comutil.h> |
49 | 50 |
|
50 | | -**Lib:** comsuppw.lib or comsuppwd.lib (see [/Zc:wchar_t (wchar_t Is Native Type)](../build/reference/zc-wchar-t-wchar-t-is-native-type.md) for more information) |
| 51 | +**Lib:** *`comsuppw.lib`* or *`comsuppwd.lib`* (For more information, see [`/Zc:wchar_t` (wchar_t is native type)](../build/reference/zc-wchar-t-wchar-t-is-native-type.md)) |
51 | 52 |
|
52 | 53 | ## See also |
53 | 54 |
|
54 | | -[Compiler COM Support Classes](../cpp/compiler-com-support-classes.md) |
| 55 | +[Compiler COM support classes](../cpp/compiler-com-support-classes.md) |
0 commit comments