未验证 提交 22de912c 编写于 作者: H hangy 提交者: GitHub

Move Interop code from System.Drawings.Common to Common directory (#77565)

* Move Library names to Common directory

* Move ExtractAssociatedIcon P/Invoke to Interop.ExtractAssociatedIcon.cs

* Move PrintDlg P/Invoke to Interop.PrintDlg.cs

* Move Kernel32 P/Invoke to Interop.*.cs

* Move Winspool P/Invoke to Interop.*.cs

* Move User32 P/Invoke to Interop.*.cs

* Move Gdi32 P/Invoke to Interop.*.cs
上级 ad05ff7d
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int AbortDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int AddFontResourceEx(string lpszFilename, int fl, IntPtr pdv);
internal static int AddFontFile(string fileName)
{
return AddFontResourceEx(fileName, /*FR_PRIVATE*/ 0x10, IntPtr.Zero);
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Gdi32
{
internal const int BITMAPINFO_MAX_COLORSIZE = 256;
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct BITMAPINFO_FLAT
{
public int bmiHeader_biSize; // = sizeof(BITMAPINFOHEADER)
public int bmiHeader_biWidth;
public int bmiHeader_biHeight;
public short bmiHeader_biPlanes;
public short bmiHeader_biBitCount;
public int bmiHeader_biCompression;
public int bmiHeader_biSizeImage;
public int bmiHeader_biXPelsPerMeter;
public int bmiHeader_biYPelsPerMeter;
public int bmiHeader_biClrUsed;
public int bmiHeader_biClrImportant;
public fixed byte bmiColors[BITMAPINFO_MAX_COLORSIZE * 4]; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat...
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr CreateCompatibleBitmap(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int width, int height);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr CreateDIBSection(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset);
}
}
......@@ -11,219 +11,6 @@ internal static partial class Interop
{
internal static partial class Gdi32
{
internal const int QUERYESCSUPPORT = 8;
internal const int CHECKJPEGFORMAT = 4119;
internal const int CHECKPNGFORMAT = 4120;
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr CreateCompatibleBitmap(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int width, int height);
[LibraryImport(Libraries.Gdi32)]
internal static partial int GetDIBits(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hdc,
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5);
[LibraryImport(Libraries.Gdi32)]
internal static partial uint GetPaletteEntries(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr CreateDIBSection(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset);
[LibraryImport(Libraries.Gdi32, EntryPoint = "StartDocW", SetLastError = true)]
internal static partial int StartDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, in DOCINFO lpDocInfo);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int StartPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int AbortDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
[LibraryImport(Libraries.Gdi32, EntryPoint = "ResetDCW", SetLastError = true)]
internal static partial IntPtr /*HDC*/ ResetDC(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC,
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef /*DEVMODE*/ lpDevMode);
[LibraryImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int AddFontResourceEx(string lpszFilename, int fl, IntPtr pdv);
internal static int AddFontFile(string fileName)
{
return AddFontResourceEx(fileName, /*FR_PRIVATE*/ 0x10, IntPtr.Zero);
}
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int IntersectClipRect(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int x1, int y1, int x2, int y2);
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)]
internal static partial int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, int nSize, ref BITMAP bm);
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf);
internal static unsafe int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, ref Interop.User32.LOGFONT lp)
=> GetObject(hObject, sizeof(Interop.User32.LOGFONT), ref lp);
[StructLayout(LayoutKind.Sequential)]
public struct BITMAP
{
public uint bmType;
public uint bmWidth;
public uint bmHeight;
public uint bmWidthBytes;
public ushort bmPlanes;
public ushort bmBitsPixel;
public IntPtr bmBits;
}
internal const int BITMAPINFO_MAX_COLORSIZE = 256;
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct BITMAPINFO_FLAT
{
public int bmiHeader_biSize; // = sizeof(BITMAPINFOHEADER)
public int bmiHeader_biWidth;
public int bmiHeader_biHeight;
public short bmiHeader_biPlanes;
public short bmiHeader_biBitCount;
public int bmiHeader_biCompression;
public int bmiHeader_biSizeImage;
public int bmiHeader_biXPelsPerMeter;
public int bmiHeader_biYPelsPerMeter;
public int bmiHeader_biClrUsed;
public int bmiHeader_biClrImportant;
public fixed byte bmiColors[BITMAPINFO_MAX_COLORSIZE * 4]; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat...
}
#if NET7_0_OR_GREATER
[NativeMarshalling(typeof(Marshaller))]
#endif
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct DOCINFO
{
internal int cbSize = 20;
internal string? lpszDocName;
internal string? lpszOutput;
internal string? lpszDatatype;
internal int fwType;
public DOCINFO() { }
#if NET7_0_OR_GREATER
[CustomMarshaller(typeof(DOCINFO), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))]
public static class Marshaller
{
public static Native ConvertToUnmanaged(DOCINFO managed) => new(managed);
public static void Free(Native native) => native.FreeNative();
internal struct Native
{
internal int cbSize;
internal IntPtr lpszDocName;
internal IntPtr lpszOutput;
internal IntPtr lpszDatatype;
internal int fwType;
public Native(DOCINFO docInfo)
{
cbSize = docInfo.cbSize;
lpszDocName = Marshal.StringToCoTaskMemAuto(docInfo.lpszDocName);
lpszOutput = Marshal.StringToCoTaskMemAuto(docInfo.lpszOutput);
lpszDatatype = Marshal.StringToCoTaskMemAuto(docInfo.lpszDatatype);
fwType = docInfo.fwType;
}
public void FreeNative()
{
Marshal.FreeCoTaskMem(lpszDocName);
Marshal.FreeCoTaskMem(lpszOutput);
Marshal.FreeCoTaskMem(lpszDatatype);
}
}
}
#endif
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public sealed class DEVMODE
{
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int EndPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
internal const int QUERYESCSUPPORT = 8;
internal const int CHECKJPEGFORMAT = 4119;
internal const int CHECKPNGFORMAT = 4120;
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData);
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int ExtEscape(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32)]
internal static partial int GetDIBits(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hdc,
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)]
internal static partial int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, int nSize, ref BITMAP bm);
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf);
internal static unsafe int GetObject(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hObject, ref Interop.User32.LOGFONT lp)
=> GetObject(hObject, sizeof(Interop.User32.LOGFONT), ref lp);
[StructLayout(LayoutKind.Sequential)]
public struct BITMAP
{
public uint bmType;
public uint bmWidth;
public uint bmHeight;
public uint bmWidthBytes;
public ushort bmPlanes;
public ushort bmBitsPixel;
public IntPtr bmBits;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32)]
internal static partial uint GetPaletteEntries(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int IntersectClipRect(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, int x1, int y1, int x2, int y2);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, EntryPoint = "ResetDCW", SetLastError = true)]
internal static partial IntPtr /*HDC*/ ResetDC(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC,
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef /*DEVMODE*/ lpDevMode);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, EntryPoint = "StartDocW", SetLastError = true)]
internal static partial int StartDoc(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC, in DOCINFO lpDocInfo);
#if NET7_0_OR_GREATER
[NativeMarshalling(typeof(Marshaller))]
#endif
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct DOCINFO
{
internal int cbSize = 20;
internal string? lpszDocName;
internal string? lpszOutput;
internal string? lpszDatatype;
internal int fwType;
public DOCINFO() { }
#if NET7_0_OR_GREATER
[CustomMarshaller(typeof(DOCINFO), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))]
public static class Marshaller
{
public static Native ConvertToUnmanaged(DOCINFO managed) => new(managed);
public static void Free(Native native) => native.FreeNative();
internal struct Native
{
internal int cbSize;
internal IntPtr lpszDocName;
internal IntPtr lpszOutput;
internal IntPtr lpszDatatype;
internal int fwType;
public Native(DOCINFO docInfo)
{
cbSize = docInfo.cbSize;
lpszDocName = Marshal.StringToCoTaskMemAuto(docInfo.lpszDocName);
lpszOutput = Marshal.StringToCoTaskMemAuto(docInfo.lpszOutput);
lpszDatatype = Marshal.StringToCoTaskMemAuto(docInfo.lpszDatatype);
fwType = docInfo.fwType;
}
public void FreeNative()
{
Marshal.FreeCoTaskMem(lpszDocName);
Marshal.FreeCoTaskMem(lpszOutput);
Marshal.FreeCoTaskMem(lpszDatatype);
}
}
}
#endif
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Gdi32
{
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial int StartPage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hDC);
}
}
......@@ -47,5 +47,9 @@ internal static partial class Libraries
internal const string HostPolicy = "hostpolicy";
internal const string Ucrtbase = "ucrtbase.dll";
internal const string Xolehlp = "xolehlp.dll";
internal const string Comdlg32 = "comdlg32.dll";
internal const string Gdiplus = "gdiplus.dll";
internal const string Oleaut32 = "oleaut32.dll";
internal const string Winspool = "winspool.drv";
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Libraries
internal static partial class Kernel32
{
internal const string Gdiplus = "gdiplus";
[LibraryImport(Libraries.Kernel32, SetLastError = true)]
public static partial int GetSystemDefaultLCID();
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Kernel32
{
[LibraryImport(Libraries.Kernel32, EntryPoint = "GlobalAlloc", SetLastError = true)]
internal static partial IntPtr IntGlobalAlloc(int uFlags, UIntPtr dwBytes); // size should be 32/64bits compatible
internal static IntPtr GlobalAlloc(int uFlags, uint dwBytes)
{
return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes));
}
}
}
......@@ -11,17 +11,6 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
[LibraryImport(Libraries.Kernel32, SetLastError = true)]
public static partial int GetSystemDefaultLCID();
[LibraryImport(Libraries.Kernel32, EntryPoint = "GlobalAlloc", SetLastError = true)]
internal static partial IntPtr IntGlobalAlloc(int uFlags, UIntPtr dwBytes); // size should be 32/64bits compatible
internal static IntPtr GlobalAlloc(int uFlags, uint dwBytes)
{
return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes));
}
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
internal static partial IntPtr SelectObject(
#if NET7_0_OR_GREATER
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, SetLastError = true)]
internal static partial IntPtr CopyImage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, SetLastError = true)]
internal static unsafe partial IntPtr CreateIconFromResourceEx(byte* pbIconBits, uint cbIconBits, [MarshalAs(UnmanagedType.Bool)] bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DestroyIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hIcon);
}
}
......@@ -11,39 +11,6 @@ internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)]
internal static partial IntPtr LoadIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hInst, IntPtr iconId);
[LibraryImport(Libraries.User32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DestroyIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hIcon);
[LibraryImport(Libraries.User32, SetLastError = true)]
internal static partial IntPtr CopyImage(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
[LibraryImport(Libraries.User32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool GetIconInfo(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hIcon, ref ICONINFO info);
[LibraryImport(Libraries.User32, SetLastError = true)]
public static partial int GetSystemMetrics(int nIndex);
[LibraryImport(Libraries.User32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool DrawIconEx(
......@@ -59,18 +26,5 @@ internal static partial class User32
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hBrushFlickerFree, int diFlags);
[LibraryImport(Libraries.User32, SetLastError = true)]
internal static unsafe partial IntPtr CreateIconFromResourceEx(byte* pbIconBits, uint cbIconBits, [MarshalAs(UnmanagedType.Bool)] bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags);
[StructLayout(LayoutKind.Sequential)]
internal struct ICONINFO
{
internal uint fIcon;
internal uint xHotspot;
internal uint yHotspot;
internal IntPtr hbmMask;
internal IntPtr hbmColor;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool GetIconInfo(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hIcon, ref ICONINFO info);
[StructLayout(LayoutKind.Sequential)]
internal struct ICONINFO
{
internal uint fIcon;
internal uint xHotspot;
internal uint yHotspot;
internal IntPtr hbmMask;
internal IntPtr hbmColor;
}
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Libraries
internal static partial class User32
{
internal const string Comdlg32 = "comdlg32.dll";
internal const string Gdiplus = "gdiplus.dll";
internal const string Oleaut32 = "oleaut32.dll";
internal const string Winspool = "winspool.drv";
[LibraryImport(Libraries.User32, SetLastError = true)]
public static partial int GetSystemMetrics(int nIndex);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class User32
{
[LibraryImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)]
internal static partial IntPtr LoadIcon(
#if NET7_0_OR_GREATER
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hInst, IntPtr iconId);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Winspool
{
[LibraryImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr /*DEVMODE*/ pDevMode);
}
}
......@@ -11,9 +11,6 @@ internal static partial class Interop
{
internal static partial class Winspool
{
[LibraryImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr /*DEVMODE*/ pDevMode);
[LibraryImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int DocumentProperties(
#if NET7_0_OR_GREATER
......@@ -39,8 +36,5 @@ internal static partial class Winspool
[MarshalUsing(typeof(HandleRefMarshaller))]
#endif
HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, IntPtr /*DEVMODE*/ pDevModeInput, int fMode);
[LibraryImport(Libraries.Winspool, EntryPoint = "EnumPrintersW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/, int cbBuf, out int pcbNeeded, out int pcReturned);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif
internal static partial class Interop
{
internal static partial class Winspool
{
[LibraryImport(Libraries.Winspool, EntryPoint = "EnumPrintersW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/, int cbBuf, out int pcbNeeded, out int pcReturned);
}
}
......@@ -214,24 +214,29 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
<Compile Include="misc\GDI\DeviceContextType.cs" />
<Compile Include="misc\GDI\WindowsGraphics.cs" />
<Compile Include="misc\GDI\WindowsRegion.cs" />
<Compile Include="Interop\Windows\Interop.Comdlg32.cs" />
<Compile Include="Interop\Windows\Interop.Gdi32.cs" />
<Compile Include="Interop\Windows\Interop.Kernel32.cs" />
<Compile Include="Interop\Windows\Interop.Libraries.cs" />
<Compile Include="Interop\Windows\Interop.Shell32.cs" />
<Compile Include="Interop\Windows\Interop.User32.cs" />
<Compile Include="Interop\Windows\Interop.Winspool.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.BOOL.cs"
Link="Common\Interop\Windows\Interop.BOOL.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Comdlg32\Interop.PrintDlg.cs"
Link="Common\Interop\Windows\Comdlg32\Interop.PrintDlg.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.AbortDoc.cs"
Link="Common\Interop\Windows\Gdi32\Interop.AbortDoc.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.AddFontResourceEx.cs"
Link="Common\Interop\Windows\Gdi32\Interop.AddFontResourceEx.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.BITMAPINFO_FLAT.cs"
Link="Common\Interop\Windows\Gdi32\Interop.BITMAPINFO_FLAT.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CombineRgn.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CombineRgn.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateCompatibleBitmap.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CreateCompatibleBitmap.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateCompatibleDC.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CreateCompatibleDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateDC.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CreateDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateDIBSection.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CreateDIBSection.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateIC.cs"
Link="Common\Interop\Windows\Gdi32\Interop.CreateIC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.CreateFontIndirect.cs"
......@@ -242,18 +247,40 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
Link="Common\Interop\Windows\Gdi32\Interop.DeleteDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.DeleteObject.cs"
Link="Common\Interop\Windows\Gdi32\Interop.DeleteObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.DEVMODE.cs"
Link="Common\Interop\Windows\Gdi32\Interop.DEVMODE.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.EndDoc.cs"
Link="Common\Interop\Windows\Gdi32\Interop.EndDoc.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.EndPage.cs"
Link="Common\Interop\Windows\Gdi32\Interop.EndPage.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.ExtEscape.cs"
Link="Common\Interop\Windows\Gdi32\Interop.ExtEscape.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetClipRgn.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetClipRgn.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetCurrentObject.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetCurrentObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetDeviceCaps.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetDeviceCaps.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetDIBits.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetDIBits.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetObject.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetObjectType.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetObjectType.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetPaletteEntries.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetPaletteEntries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetRgnBox.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetRgnBox.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.GetStockObject.cs"
Link="Common\Interop\Windows\Gdi32\Interop.GetStockObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.IntersectClipRect.cs"
Link="Common\Interop\Windows\Gdi32\Interop.IntersectClipRect.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.ResetDC.cs"
Link="Common\Interop\Windows\Gdi32\Interop.ResetDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.StartDoc.cs"
Link="Common\Interop\Windows\Gdi32\Interop.StartDoc.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.StartPage.cs"
Link="Common\Interop\Windows\Gdi32\Interop.StartPage.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs"
Link="Common\Interop\Windows\Ole32\Interop.IStream.COMWrappers.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.ObjectType.cs"
......@@ -272,10 +299,16 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
Link="Common\Interop\Windows\Gdi32\Interop.SaveDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.SelectClipRgn.cs"
Link="Common\Interop\Windows\Gdi32\Interop.SelectClipRgn.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetSystemDefaultLCID.cs"
Link="Common\Interop\Windows\Kernel32\Interop.GetSystemDefaultLCID.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GlobalAlloc.cs"
Link="Common\Interop\Windows\Kernel32\Interop.GlobalAlloc.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GlobalFree.cs"
Link="Common\Interop\Windows\Kernel32\Interop.GlobalFree.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GlobalLock.cs"
Link="Common\Interop\Windows\Kernel32\Interop.GlobalLock.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SelectObject.cs"
Link="Common\Interop\Windows\Kernel32\Interop.SelectObject.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.BitBlt.cs"
Link="Common\Interop\Windows\Gdi32\Interop.BitBlt.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Ole32\Interop.STATSTG.cs"
......@@ -286,8 +319,24 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
Link="Common\Interop\Windows\Ole32\Interop.STATFLAG.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Ole32\Interop.STGM.cs"
Link="Common\Interop\Windows\Ole32\Interop.STGM.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Shell32\Interop.ExtractAssociatedIcon.cs"
Link="Common\Interop\Windows\Shell32\Interop.ExtractAssociatedIcon.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.CopyImage.cs"
Link="Common\Interop\Windows\User32\Interop.CopyImage.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.CreateIconFromResourceEx.cs"
Link="Common\Interop\Windows\User32\Interop.CreateIconFromResourceEx.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.DestroyIcon.cs"
Link="Common\Interop\Windows\User32\Interop.DestroyIcon.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.DrawIconEx.cs"
Link="Common\Interop\Windows\User32\Interop.DrawIconEx.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.GetDC.cs"
Link="Common\Interop\Windows\User32\Interop.GetDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.GetIconInfo.cs"
Link="Common\Interop\Windows\User32\Interop.GetIconInfo.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.GetSystemMetrics.cs"
Link="Common\Interop\Windows\User32\Interop.GetSystemMetrics.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.LoadIcon.cs"
Link="Common\Interop\Windows\User32\Interop.LoadIcon.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.LOGFONT.cs"
Link="Common\Interop\Windows\User32\Interop.LOGFONT.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.ReleaseDC.cs"
......@@ -298,6 +347,12 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
Link="Common\Interop\Windows\User32\Interop.NONCLIENTMETRICS.cs" />
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.WindowFromDC.cs"
Link="Common\Interop\Windows\User32\Interop.WindowFromDC.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Winspool\Interop.DeviceCapabilities.cs"
Link="Common\Interop\Windows\Winspool\Interop.DeviceCapabilities.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Winspool\Interop.DocumentProperties.cs"
Link="Common\Interop\Windows\Winspool\Interop.DocumentProperties.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Winspool\Interop.EnumPrinters.cs"
Link="Common\Interop\Windows\Winspool\Interop.EnumPrinters.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.HRESULT.cs"
Link="Common\Interop\Windows\Interop.HRESULT.cs" />
<Compile Include="$(CommonPath)System\LocalAppContextSwitches.Common.cs"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册