示例#1
0
 /// <summary>
 /// Allocates from unmanaged memory to represent a Unicode string (WSTR)
 /// and marshal this to a native PWSTR.
 /// </summary>
 /// <param name="s">String</param>
 /// <returns>SafeHGlobalHandle object to an native (unmanaged) Unicode string</returns>
 public SafeHGlobalHandle(string s) : this(s == null ? IntPtr.Zero : Marshal.StringToHGlobalUni(s), (s?.Length + 1) * 2 ?? 0)
 {
 }