System.Runtime.InteropServices.Marshal.FreeBSTR Method

Frees a BSTR using the COM tp://go.microsoft.com/fwlink/?LinkID=148633 function.

Syntax

public static void FreeBSTR (IntPtr ptr)

Parameters

ptr
The address of the BSTR to be freed.

Remarks

Like Marshal.FreeCoTaskMem(IntPtr) and Marshal.FreeHGlobal(IntPtr), you can use this method to deallocate memory. Marshal.FreeBSTR(IntPtr) calls the COM tp://go.microsoft.com/fwlink/?LinkID=148633 function, which frees memory allocated by any of the following unmanaged methods: SysAllocString, SysAllocStringByteLen, SysAllocStringLen, SysReAllocString, SysReAllocStringLen. You can call unmanaged methods such as these with platform invoke. For details, see [<topic://cpconconsumingunmanageddllfunctions>].

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0