命名空間:
System.Runtime.InteropServices
程序集:
System.Runtime.InteropServices.dll, mscorlib.dll, netstandard.dll
將托管 String 的內(nèi)容復(fù)制到非托管內(nèi)存,并在復(fù)制時(shí)轉(zhuǎn)換為 ANSI 格式。
C#
[System.Security.SecurityCritical]
public static IntPtr StringToHGlobalAnsi (string s);
?
參數(shù)
s
String
要復(fù)制的托管字符串。
返回
IntPtr
非托管內(nèi)存中將 s 復(fù)制到其中的地址;如果 s 為 null,則為 0。
屬性
SecurityCriticalAttribute
異常
OutOfMemoryException
沒有足夠的可用內(nèi)存。
ArgumentOutOfRangeException
s 參數(shù)超過了操作系統(tǒng)所允許的最大長度。