This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
public:
static System::String ^ PtrToStringUni(IntPtr ptr);
[System.Security.SecurityCritical]
public static string PtrToStringUni (IntPtr ptr);
public static string? PtrToStringUni (IntPtr ptr);
public static string PtrToStringUni (IntPtr ptr);
[<System.Security.SecurityCritical>]
static member PtrToStringUni : nativeint -> string
static member PtrToStringUni : nativeint -> string
Public Shared Function PtrToStringUni (ptr As IntPtr) As String
Parameters
Remarks
PtrToStringUni
is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the
Marshal.StringToCoTaskMemUni
and
Marshal.StringToHGlobalUni
methods.
This API reflects the Windows definition of Unicode, which is a UTF-16 2-byte encoding. On many non-Windows platforms, the
wchar_t
data-type is 4-bytes, not 2-bytes. Consult your compiler to confirm if
wchar_t
can be used or
char16_t
should be used instead.
public:
static System::String ^ PtrToStringUni(IntPtr ptr, int len);
[System.Security.SecurityCritical]
public static string PtrToStringUni (IntPtr ptr, int len);
public static string PtrToStringUni (IntPtr ptr, int len);
[<System.Security.SecurityCritical>]
static member PtrToStringUni : nativeint * int -> string
static member PtrToStringUni : nativeint * int -> string
Public Shared Function PtrToStringUni (ptr As IntPtr, len As Integer) As String
Parameters
Remarks
PtrToStringUni
is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the
Marshal.StringToCoTaskMemUni
and
Marshal.StringToHGlobalUni
methods.
This API reflects the Windows definition of Unicode, which is a UTF-16 2-byte encoding. On many non-Windows platforms, the
wchar_t
data-type is 4-bytes, not 2-bytes. Consult your compiler to confirm if
wchar_t
can be used or
char16_t
should be used instead.