Beispiel #1
0
 public static unsafe void StringToHStringReference(
     char *pchPinnedSourceString,
     string sourceString,
     HSTRING_HEADER *pHeader,
     HSTRING *phString)
 {
     throw new PlatformNotSupportedException("StringToHStringReference");
 }
        public static unsafe void StringToHStringReference(
            char *pchPinnedSourceString,
            string sourceString,
            HSTRING_HEADER *pHeader,
            HSTRING *phString)
        {
            if (sourceString == null)
            {
                throw new ArgumentNullException(nameof(sourceString), SR.Null_HString);
            }

            int hr = ExternalInterop.WindowsCreateStringReference(
                pchPinnedSourceString,
                (uint)sourceString.Length,
                pHeader,
                (void **)phString);

            if (hr < 0)
            {
                throw Marshal.GetExceptionForHR(hr);
            }
        }
Beispiel #3
0
        internal unsafe static IntPtr ConvertToNativeReference(string managed, [Out] HSTRING_HEADER *hstringHeader)
        {
            if (!Environment.IsWinRTSupported)
            {
                throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT"));
            }
            if (managed == null)
            {
                throw new ArgumentNullException();
            }
            char *ptr = managed;

            if (ptr != null)
            {
                ptr += RuntimeHelpers.OffsetToStringData / 2;
            }
            IntPtr result;
            int    errorCode = UnsafeNativeMethods.WindowsCreateStringReference(ptr, managed.Length, hstringHeader, &result);

            Marshal.ThrowExceptionForHR(errorCode, new IntPtr(-1));
            return(result);
        }
Beispiel #4
0
        internal static unsafe IntPtr ConvertToNativeReference(string managed, [Out] HSTRING_HEADER *hstringHeader)
        {
            if (!Environment.IsWinRTSupported)
            {
                throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT"));
            }
            if (managed == null)
            {
                throw new ArgumentNullException();
            }
            string str          = managed;
            char * sourceString = (char *)str;

            if ((IntPtr)sourceString != IntPtr.Zero)
            {
                sourceString += RuntimeHelpers.OffsetToStringData;
            }
            IntPtr num;

            Marshal.ThrowExceptionForHR(UnsafeNativeMethods.WindowsCreateStringReference(sourceString, managed.Length, hstringHeader, &num), new IntPtr(-1));
            return(num);
        }
 internal static unsafe extern int WindowsCreateStringReference(char *sourceString,
                                                                int length,
                                                                [Out] HSTRING_HEADER *hstringHeader,
                                                                [Out] IntPtr *hstring);
 internal static extern unsafe int WindowsCreateStringReference(char *sourceString,
                                                                uint length,
                                                                HSTRING_HEADER *phstringHeader,
                                                                void *hstring);
Beispiel #7
0
 public static extern HRESULT WindowsCreateStringReference([NativeTypeName("PCWSTR")] ushort *sourceString, [NativeTypeName("UINT32")] uint length, HSTRING_HEADER *hstringHeader, HSTRING * @string);
Beispiel #8
0
 public static extern int WindowsCreateStringReference([NativeTypeName("PCWSTR")] ushort *sourceString, [NativeTypeName("UINT32")] uint length, [NativeTypeName("HSTRING_HEADER *")] HSTRING_HEADER *hstringHeader, [NativeTypeName("HSTRING *")] IntPtr * @string);