FreeBSTR Method
Collapse the table of content
Expand the table of content

Marshal.FreeBSTR Method (IntPtr)


Frees a BSTR using the COM SysFreeString function.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public static void FreeBSTR(
	IntPtr ptr


Type: System.IntPtr

The address of the BSTR to be freed.

Like Marshal.FreeCoTaskMem and Marshal.FreeHGlobal, you can use this method to deallocate memory. FreeBSTR calls the COM SysFreeString 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 Consuming Unmanaged DLL Functions.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft