Example #1
0
        internal static SafeBSTRHandle Allocate(String src, uint len)
        {
            SafeBSTRHandle bstr = SysAllocStringLen(src, len);

            bstr.Initialize(len * sizeof(char));
            return(bstr);
        }
Example #2
0
        internal static SafeBSTRHandle Allocate(string src, uint len)
        {
            SafeBSTRHandle handle = SysAllocStringLen(src, len);

            handle.Initialize((ulong)(len * 2));
            return(handle);
        }
Example #3
0
        internal static SafeBSTRHandle Allocate(IntPtr src, uint lenInBytes)
        {
            SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInBytes / sizeof(char));

            bstr.Initialize(lenInBytes);
            return(bstr);
        }
Example #4
0
        internal static SafeBSTRHandle Allocate(string src, uint len)
        {
            SafeBSTRHandle safeBstrHandle = SafeBSTRHandle.SysAllocStringLen(src, len);
            long           num            = (long)(len * 2U);

            safeBstrHandle.Initialize((ulong)num);
            return(safeBstrHandle);
        }
Example #5
0
        internal static SafeBSTRHandle Allocate(string src, uint lenInChars)
        {
            SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInChars);

            if (bstr.IsInvalid) // SysAllocStringLen returns a NULL ptr when there's insufficient memory
            {
                throw new OutOfMemoryException();
            }
            bstr.Initialize(lenInChars * sizeof(char));
            return(bstr);
        }
Example #6
0
        internal static SafeBSTRHandle Allocate(IntPtr src, uint lenInBytes)
        {
            Debug.Assert(lenInBytes % sizeof(char) == 0);
            SafeBSTRHandle bstr = Interop.OleAut32.SysAllocStringLen(src, lenInBytes / sizeof(char));

            if (bstr.IsInvalid) // SysAllocStringLen returns a NULL ptr when there's insufficient memory
            {
                throw new OutOfMemoryException();
            }
            bstr.Initialize(lenInBytes);
            return(bstr);
        }