語言

Marshal.PtrToStringBSTR(IntPtr) 方法

定義

分配一個受管理 String 的,並將儲存在非管理記憶體中的 二進位字串(BSTR )複製到該記憶體中。

public:
 static System::String ^ PtrToStringBSTR(IntPtr ptr);
[System.Security.SecurityCritical]
public static string PtrToStringBSTR(IntPtr ptr);
public static string PtrToStringBSTR(IntPtr ptr);
[<System.Security.SecurityCritical>]
static member PtrToStringBSTR : nativeint -> string
static member PtrToStringBSTR : nativeint -> string
Public Shared Function PtrToStringBSTR (ptr As IntPtr) As String

參數

ptr
IntPtr

nativeint

未管理字串的第一個字元位址。

傳回

一個管理字串,用來保存未管理字串的副本。

屬性

例外狀況

備註

僅在分配了未管理的 SysAllocString 與 SysAllocStringLen 函式的字串上呼叫此方法。

PtrToStringBSTR 適用於自訂編組或混合管理與非管理程式碼時。 由於此方法會產生未管理字串內容的副本,因此必須適當地釋放原始字串。 此方法提供與該 Marshal.StringToBSTR 方法相反的功能。

適用於

另請參閱