コード例 #1
0
        public unsafe Stream GetThemeStream(
            int partId, int stateId, int propertyId, SafeModuleHandle instance)
        {
            HResult hr = UxThemeExNativeMethods.UxGetThemeStream(
                themeFile, theme, partId, stateId, propertyId, out IntPtr stream,
                out uint length, instance);

            if (!Found(hr) || stream == IntPtr.Zero)
            {
                return(null);
            }

            var buffer = new byte[length];

            if (length > 0)
            {
                Marshal.Copy(stream, buffer, 0, buffer.Length);
            }
            return(new UnmanagedMemoryStream(
                       (byte *)stream.ToPointer(), 0, length, FileAccess.Read));
        }