com.sun.jna.platform.win32

## Class WTypes.BSTR

- java.lang.Object
- - com.sun.jna.PointerType
  - - com.sun.jna.platform.win32.WTypes.BSTR

All Implemented Interfaces:
  NativeMapped

Enclosing interface:
  WTypes

    public static class WTypes.BSTR
    extends PointerType

BSTR wrapper.

From MSDN:

> A BSTR (Basic string or binary string) is a string data type that is used by COM, Automation, and Interop functions. Use the BSTR data type in all interfaces that will be accessed from script.

The memory structure:

Length prefix
  Length of the data array holding the string data and does not include the final two NULL characters.
Data string
  UTF-16LE encoded bytes for the string.
Terminator
  Two null characters

The "value" of the BSTR is the pointer to the start of the Data String, the length prefix is the four bytes before that.

The MSDN states, that a BSTR derived from a Nullpointer is treated as a string containing zero characters.

### Constructor Summary

Constructors
Constructor and Description
`BSTR()`
`BSTR(Pointer pointer)` Instantiate a BSTR from a pointer.
`BSTR(java.lang.String value)` Deprecated. Use `OleAuto.SysAllocString(String)` and `OleAuto.SysFreeString(com.sun.jna.platform.win32.WTypes.BSTR)`

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`java.lang.String` `getValue()`
`void` `setValue(java.lang.String value)` Deprecated. Users should not change the value of an allocated `WTypes.BSTR`.
`java.lang.String` `toString()`

### Methods inherited from class com.sun.jna.PointerType

`equals, fromNative, getPointer, hashCode, nativeType, setPointer, toNative`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### BSTR

    public BSTR()

#### BSTR

    public BSTR(Pointer pointer)

Instantiate a BSTR from a pointer. The user is responsible for allocating and releasing memory for the `WTypes.BSTR`, most commonly using `OleAuto.SysAllocString(String)` and `OleAuto.SysFreeString(com.sun.jna.platform.win32.WTypes.BSTR)`

Parameters:
  `pointer` - A pointer to the string

#### BSTR

    @Deprecated
    public BSTR(java.lang.String value)

Deprecated. Use `OleAuto.SysAllocString(String)` and `OleAuto.SysFreeString(com.sun.jna.platform.win32.WTypes.BSTR)`

### Method Detail

#### setValue

    @Deprecated
    public void setValue(java.lang.String value)

Deprecated. Users should not change the value of an allocated `WTypes.BSTR`.

#### getValue

    public java.lang.String getValue()

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `PointerType`

Copyright © 2007-2018 Timothy Wall. All Rights Reserved.