SecureStringMarshal.SecureStringToCoTaskMemUnicode(SecureString) 方法

定义

将托管 SecureString 对象的内容复制到从非托管 COM 任务分配器分配的内存块。Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.

public:
 static IntPtr SecureStringToCoTaskMemUnicode(System::Security::SecureString ^ s);
public static IntPtr SecureStringToCoTaskMemUnicode (System.Security.SecureString s);
static member SecureStringToCoTaskMemUnicode : System.Security.SecureString -> nativeint
Public Shared Function SecureStringToCoTaskMemUnicode (s As SecureString) As IntPtr

参数

s
SecureString

要复制的托管对象。The managed object to copy.

返回

IntPtr

非托管内存中将 s 参数复制到的地址;如果提供了 null 对象,则为 0。The address, in unmanaged memory, where the s parameter was copied to, or 0 if a null object was supplied.

例外

s 参数为 nullThe s parameter is null.

没有足够的可用内存。There is insufficient memory available.

注解

SecureStringToCoTaskMemUnicode 方法对于自定义封送或混合托管和非托管代码很有用。The SecureStringToCoTaskMemUnicode method is useful for custom marshaling or when mixing managed and unmanaged code. 由于此方法会分配字符串所需的非托管内存,因此请始终通过调用方法来释放内存 ZeroFreeCoTaskMemUnicodeBecause this method allocates the unmanaged memory required for a string, always free the memory by calling the ZeroFreeCoTaskMemUnicode method. 将字符串的字符作为 Unicode 字符进行复制。The characters of the string are copied as Unicode characters.

适用于