public unsafe static IntPtr AllocBString(string str) { if (str == null) { return(IntPtr.Zero); } byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str); var bstr = BStringVTable.Create(bytes.Length); byte * dataptr = GetBStringDataPtr(bstr); Marshal.Copy(bytes, 0, (IntPtr)dataptr, bytes.Length); return(bstr); }
public unsafe static IntPtr AllocZeroBString(int length) { return(BStringVTable.Create(length)); }