SecureStringMarshal.SecureStringToGlobalAllocAnsi(SecureString) 方法
定义
将托管 SecureString 的内容复制到非托管内存,并在复制时转换为 ANSI 格式。Copies the contents of a managed SecureString into unmanaged memory, converting into ANSI format as it copies.
public:
static IntPtr SecureStringToGlobalAllocAnsi(System::Security::SecureString ^ s);
public static IntPtr SecureStringToGlobalAllocAnsi (System.Security.SecureString s);
static member SecureStringToGlobalAllocAnsi : System.Security.SecureString -> nativeint
Public Shared Function SecureStringToGlobalAllocAnsi (s As SecureString) As IntPtr
参数
要复制的托管对象。The managed object to copy.
返回
非托管内存中将 s 参数复制到的地址,或者,如果提供了 null 对象,则为 0。The address, in unmanaged memory, to where the s parameter was copied, or 0 if a null object was supplied.
例外
s 参数为 null。The s parameter is null.
没有足够的可用内存。There is insufficient memory available.
注解
此 SecureStringToGlobalAllocAnsi 方法对于自定义封送或混合托管和非托管代码很有用。The SecureStringToGlobalAllocAnsi method is useful for custom marshaling or when mixing managed and unmanaged code. 由于此方法会分配字符串所需的非托管内存,因此请始终通过调用方法来释放内存 ZeroFreeGlobalAllocAnsi 。Because this method allocates the unmanaged memory required for a string, always free the memory by calling the ZeroFreeGlobalAllocAnsi method.