Marshal.FreeBSTR Method (IntPtr)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Frees a BSTR using the COM SysFreeString function.

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

[<SecurityCriticalAttribute>]
static member FreeBSTR : 
        ptr:nativeint -> unit

Parameters

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.

SecurityCriticalAttribute

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

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top
Show: