diff --git a/src/System.Drawing.Common/src/GlobalUsings.cs b/src/System.Drawing.Common/src/GlobalUsings.cs
index a1a1ea28d85..26442f92924 100644
--- a/src/System.Drawing.Common/src/GlobalUsings.cs
+++ b/src/System.Drawing.Common/src/GlobalUsings.cs
@@ -1,5 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+global using System;
global using System.Diagnostics;
global using System.Diagnostics.CodeAnalysis;
+global using Windows.Win32;
+global using Windows.Win32.Foundation;
+global using Windows.Win32.Graphics.Gdi;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs b/src/System.Drawing.Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs
index e95066b1af3..2d30c0591f9 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs
@@ -1,7 +1,6 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs
index 265982115d8..48b6334a6ac 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs
@@ -1,7 +1,6 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.BitBlt.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.BitBlt.cs
index bb9337753f9..15db862a9a6 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.BitBlt.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.BitBlt.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CombineRgn.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CombineRgn.cs
index 6146ab971e5..6e1a43a1181 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CombineRgn.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CombineRgn.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs
index 2a2c2fef0be..7ef89223a5d 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleDC.cs
index 90e845b0b3b..802d59c91e0 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
index 5d0e8dd2fef..e4ed349c4e9 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs
index 6897bd06a44..3686a580f29 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
index a581c5f4873..0c4a4329f83 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateIC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateRectRgn.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateRectRgn.cs
index 7affc9428ca..09af1951dd3 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateRectRgn.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.CreateRectRgn.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteDC.cs
index e5da740c46f..96a84c572de 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteObject.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteObject.cs
index 190dd3fe6f5..4f8b25d5fc7 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteObject.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.DeleteObject.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetClipRgn.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetClipRgn.cs
index 323b8d1f221..9c468d1d54b 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetClipRgn.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetClipRgn.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetCurrentObject.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetCurrentObject.cs
index f970c78ca45..cb201c24789 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetCurrentObject.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetCurrentObject.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs
index 34a965ae51c..c0446a6ab61 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDeviceCaps.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDeviceCaps.cs
index dce5a76bcb3..3fc0498a37a 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDeviceCaps.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetDeviceCaps.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs
index 1935f5cd43c..3a54598ade9 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs
@@ -1,7 +1,6 @@
// 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.Drawing.Interop;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObjectType.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObjectType.cs
index 21b9f4be6c8..fb8decf5525 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObjectType.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetObjectType.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetRgnBox.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetRgnBox.cs
index 93209757bf1..8c0befd9d04 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetRgnBox.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetRgnBox.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetStockObject.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetStockObject.cs
index 4dff4a7954b..dfcb8101c02 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetStockObject.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.GetStockObject.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.OffsetViewportOrgEx.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.OffsetViewportOrgEx.cs
index cf65a63638a..63d25a4c6ac 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.OffsetViewportOrgEx.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.OffsetViewportOrgEx.cs
@@ -1,7 +1,6 @@
// 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.Drawing;
using System.Runtime.InteropServices;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs
index 04de763cabe..f4b48a56084 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RestoreDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RestoreDC.cs
index 73c90863c3e..1dfbf697c88 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RestoreDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RestoreDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SaveDC.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SaveDC.cs
index b1d5a312931..c7b152dd467 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SaveDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SaveDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SelectClipRgn.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SelectClipRgn.cs
index 192d76ef5d1..48b8979644f 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SelectClipRgn.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.SelectClipRgn.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs
index e579a748645..326daaf5c19 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Interop.BOOL.cs b/src/System.Drawing.Common/src/Interop/Windows/Interop.BOOL.cs
deleted file mode 100644
index 619a726a75d..00000000000
--- a/src/System.Drawing.Common/src/Interop/Windows/Interop.BOOL.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-internal static partial class Interop
-{
- ///
- /// Blittable version of Windows BOOL type. It is convenient in situations where
- /// manual marshalling is required, or to avoid overhead of regular bool marshalling.
- ///
- ///
- /// Some Windows APIs return arbitrary integer values although the return type is defined
- /// as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE
- /// or bResult == BOOL.FALSE .
- ///
- internal enum BOOL : int
- {
- FALSE = 0,
- TRUE = 1,
- }
-}
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs
deleted file mode 100644
index 51d9fd22fb1..00000000000
--- a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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 Kernel32
- {
-#if NET7_0_OR_GREATER
- [LibraryImport(Libraries.Kernel32, SetLastError = true)]
- public static partial int GetSystemDefaultLCID();
-#else
- [DllImport(Libraries.Kernel32, SetLastError = true)]
- public static extern int GetSystemDefaultLCID();
-#endif
- }
-}
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs
deleted file mode 100644
index b338556b884..00000000000
--- a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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
- {
-#if NET7_0_OR_GREATER
- [LibraryImport(Libraries.Kernel32, EntryPoint = "GlobalAlloc", SetLastError = true)]
- internal static partial IntPtr IntGlobalAlloc(
-#else
- [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true, EntryPoint = "GlobalAlloc", CharSet = CharSet.Auto)]
- internal static extern IntPtr IntGlobalAlloc(
-#endif
- int uFlags,
- UIntPtr dwBytes); // size should be 32/64bits compatible
-
- internal static IntPtr GlobalAlloc(int uFlags, uint dwBytes)
- {
- return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes));
- }
- }
-}
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalFree.cs b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalFree.cs
index 3465a2447f9..2403b3ac30a 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalFree.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalFree.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalLock.cs b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalLock.cs
index 51165df6dd1..f97d3d9b377 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalLock.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.GlobalLock.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs
index d28d1ac7c5e..146b7aca34e 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.IStream.COMWrappers.cs b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.IStream.COMWrappers.cs
index e922be50899..ad8f047524c 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.IStream.COMWrappers.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.IStream.COMWrappers.cs
@@ -1,7 +1,6 @@
// 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.IO;
internal static partial class Interop
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs
index 6e1cf2c7e86..eb608fd0e21 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs
@@ -1,7 +1,6 @@
// 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;
using System.Runtime.InteropServices.ComTypes;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STGM.cs b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STGM.cs
index a946ed209d4..f9b445e9526 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STGM.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Ole32/Interop.STGM.cs
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-
internal static partial class Interop
{
internal static partial class Ole32
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs b/src/System.Drawing.Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs
index d5bf71ea98e..ee5c73f40f1 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CopyImage.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CopyImage.cs
index 66285a92aae..1a68eaa128c 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CopyImage.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CopyImage.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs
index 9711d2180c2..8e164d436ec 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs
index 149f58d5afb..41bc8c64176 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.LoadIcon.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.LoadIcon.cs
index 0644a5b48c3..c9b97980d2e 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.LoadIcon.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.LoadIcon.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.ReleaseDC.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.ReleaseDC.cs
index fb0987f8b10..494ee21938e 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.ReleaseDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.ReleaseDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.WindowFromDC.cs b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.WindowFromDC.cs
index 8b4565d572d..f1f9da29f8e 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.WindowFromDC.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/User32/Interop.WindowFromDC.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs
index 60b9fe58ed6..a15149bc109 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs
index 36eb63e9697..24bc9f5017d 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs
@@ -1,7 +1,6 @@
// 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;
diff --git a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs
index 9652855216c..52ead80fa96 100644
--- a/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs
+++ b/src/System.Drawing.Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs
@@ -1,7 +1,6 @@
// 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
diff --git a/src/System.Drawing.Common/src/NativeMethods.json b/src/System.Drawing.Common/src/NativeMethods.json
new file mode 100644
index 00000000000..e83df868da9
--- /dev/null
+++ b/src/System.Drawing.Common/src/NativeMethods.json
@@ -0,0 +1,5 @@
+{
+ "$schema": "https://aka.ms/CsWin32.schema.json",
+ "allowMarshaling": false,
+ "useSafeHandles": false
+}
\ No newline at end of file
diff --git a/src/System.Drawing.Common/src/NativeMethods.txt b/src/System.Drawing.Common/src/NativeMethods.txt
new file mode 100644
index 00000000000..0978ca56e4e
--- /dev/null
+++ b/src/System.Drawing.Common/src/NativeMethods.txt
@@ -0,0 +1,6 @@
+CreateDCW
+GetDC
+GetDCEx
+GetSystemDefaultLCID
+GlobalAlloc
+ReleaseDC
\ No newline at end of file
diff --git a/src/System.Drawing.Common/src/System.Drawing.Common.csproj b/src/System.Drawing.Common/src/System.Drawing.Common.csproj
index 8365f6f82cd..870c63997df 100644
--- a/src/System.Drawing.Common/src/System.Drawing.Common.csproj
+++ b/src/System.Drawing.Common/src/System.Drawing.Common.csproj
@@ -225,7 +225,6 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
-
@@ -239,8 +238,6 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
-
-
@@ -282,8 +279,6 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
-
-
@@ -347,6 +342,16 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
+
+
+
+
+
+
+
+
+
+
diff --git a/src/System.Drawing.Common/src/System/Drawing/Font.cs b/src/System.Drawing.Common/src/System/Drawing/Font.cs
index c16dec7f46a..a87e1568460 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Font.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Font.cs
@@ -539,7 +539,7 @@ public static Font FromHfont(IntPtr hfont)
LOGFONT logFont = default;
Gdi32.GetObject(new HandleRef(null, hfont), ref logFont);
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
return FromLogFont(in logFont, dc);
}
@@ -550,7 +550,7 @@ public static Font FromHfont(IntPtr hfont)
/// The newly created .
public static Font FromLogFont(object lf)
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
return FromLogFont(lf, dc);
}
@@ -561,7 +561,7 @@ public static Font FromLogFont(object lf)
#endif
static Font FromLogFont(in LOGFONT logFont)
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
return FromLogFont(logFont, dc);
}
@@ -689,7 +689,7 @@ private void SetFontFamily(FontFamily family)
public void ToLogFont(object logFont)
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
using Graphics graphics = Graphics.FromHdcInternal(dc);
ToLogFont(logFont, graphics);
}
@@ -697,7 +697,7 @@ public void ToLogFont(object logFont)
#if NET8_0_OR_GREATER
public void ToLogFont(out LOGFONT logFont)
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
using Graphics graphics = Graphics.FromHdcInternal(dc);
ToLogFont(out logFont, graphics);
}
@@ -708,7 +708,7 @@ public void ToLogFont(out LOGFONT logFont)
///
public IntPtr ToHfont()
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
using Graphics graphics = Graphics.FromHdcInternal(dc);
ToLogFont(out LOGFONT lf, graphics);
nint handle = Gdi32.CreateFontIndirectW(ref lf);
@@ -717,7 +717,7 @@ public IntPtr ToHfont()
public float GetHeight()
{
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
using Graphics graphics = Graphics.FromHdcInternal(dc);
return GetHeight(graphics);
}
@@ -735,7 +735,7 @@ public float SizeInPoints
return Size;
}
- using ScreenDC dc = ScreenDC.Create();
+ using var dc = GetDcScope.ScreenDC;
using Graphics graphics = Graphics.FromHdcInternal(dc);
float pixelsPerPoint = (float)(graphics.DpiY / 72.0);
diff --git a/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.Common.cs b/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.Common.cs
index 67cd744c744..69c922298b9 100644
--- a/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.Common.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.Common.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
-using static Interop;
namespace System.Drawing;
diff --git a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs
index 6087ab39bce..05bc8ecae72 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs
@@ -3092,8 +3092,8 @@ public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int desti
int destWidth = blockRegionSize.Width;
int destHeight = blockRegionSize.Height;
- nint screenDC = User32.GetDC(0);
- if (screenDC == 0)
+ using var screenDC = GetDcScope.ScreenDC;
+ if (screenDC.IsNull)
{
// ERROR_INVALID_HANDLE - if you pass an empty handle to BitBlt you'll get this error.
// Checking here to better describe test failures (and avoids taking the Graphics HDC lock).
@@ -3122,7 +3122,6 @@ public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int desti
}
finally
{
- User32.ReleaseDC(IntPtr.Zero, screenDC);
if (targetDC != 0)
{
ReleaseHdc();
diff --git a/src/System.Drawing.Common/src/System/Drawing/Icon.cs b/src/System.Drawing.Common/src/System/Drawing/Icon.cs
index 8f2682e7b0f..5331eca3d68 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Icon.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Icon.cs
@@ -493,10 +493,9 @@ private unsafe void Initialize(int width, int height)
if (s_bitDepth == 0)
{
- IntPtr dc = User32.GetDC(IntPtr.Zero);
+ using var dc = GetDcScope.ScreenDC;
s_bitDepth = Gdi32.GetDeviceCaps(dc, Gdi32.DeviceCapability.BITSPIXEL);
s_bitDepth *= Gdi32.GetDeviceCaps(dc, Gdi32.DeviceCapability.PLANES);
- User32.ReleaseDC(IntPtr.Zero, dc);
// If the bitdepth is 8, make it 4 because windows does not
// choose a 256 color icon if the display is running in 256 color mode
diff --git a/src/System.Drawing.Common/src/System/Drawing/Image.cs b/src/System.Drawing.Common/src/System/Drawing/Image.cs
index 359107c65f5..1b1c364638e 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Image.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Image.cs
@@ -12,7 +12,6 @@
using System.Runtime.InteropServices.Marshalling;
#endif
using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-using static Interop;
namespace System.Drawing;
diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs
index a43f29ef4df..5fcbb5722ae 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs
@@ -9,6 +9,7 @@
using System.IO;
using System.Runtime.InteropServices;
using static Interop;
+using Windows.Win32.System.Memory;
namespace System.Drawing.Printing;
@@ -832,7 +833,7 @@ private unsafe IntPtr GetHdevmodeInternal(string printer)
throw new InvalidPrinterException(this);
}
- IntPtr handle = Kernel32.GlobalAlloc(SafeNativeMethods.GMEM_MOVEABLE, (uint)modeSize); // cannot be <0 anyway
+ HGLOBAL handle = PInvoke.GlobalAlloc(GLOBAL_ALLOC_FLAGS.GMEM_MOVEABLE, (uint)modeSize); // cannot be <0 anyway
IntPtr pointer = Kernel32.GlobalLock(handle);
//Get the DevMode only if its not cached....
@@ -927,7 +928,7 @@ public unsafe IntPtr GetHdevnames()
// 8 = size of fixed portion of DEVNAMES
short offset = (short)(8 / Marshal.SystemDefaultCharSize); // Offsets are in characters, not bytes
uint namesSize = (uint)checked(Marshal.SystemDefaultCharSize * (offset + namesCharacters)); // always >0
- IntPtr handle = Kernel32.GlobalAlloc(SafeNativeMethods.GMEM_MOVEABLE | SafeNativeMethods.GMEM_ZEROINIT, namesSize);
+ HGLOBAL handle = PInvoke.GlobalAlloc(GLOBAL_ALLOC_FLAGS.GMEM_MOVEABLE | GLOBAL_ALLOC_FLAGS.GMEM_ZEROINIT, namesSize);
IntPtr namesPointer = Kernel32.GlobalLock(handle);
byte* pNamesPointer = (byte*)namesPointer;
diff --git a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs b/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs
deleted file mode 100644
index 5c28158d5e6..00000000000
--- a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using static Interop;
-
-namespace System.Drawing;
-
-///
-/// Simple wrapper to create a screen HDC within a using statement.
-///
-internal struct ScreenDC : IDisposable
-{
- private IntPtr _handle;
-
- public static ScreenDC Create() => new()
- {
- _handle = User32.GetDC(IntPtr.Zero)
- };
-
- public static implicit operator IntPtr(ScreenDC screenDC) => screenDC._handle;
-
- public void Dispose() => User32.ReleaseDC(IntPtr.Zero, _handle);
-}
diff --git a/src/System.Drawing.Common/src/System/Drawing/SystemFonts.cs b/src/System.Drawing.Common/src/System/Drawing/SystemFonts.cs
index d664bac8223..0289967f015 100644
--- a/src/System.Drawing.Common/src/System/Drawing/SystemFonts.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/SystemFonts.cs
@@ -173,7 +173,7 @@ public static Font DefaultFont
Font? defaultFont = null;
// For Arabic systems, always return Tahoma 8.
- if ((ushort)Kernel32.GetSystemDefaultLCID() == 0x0001)
+ if ((ushort)PInvoke.GetSystemDefaultLCID() == 0x0001)
{
try
{
@@ -230,7 +230,7 @@ public static Font DialogFont
{
Font? dialogFont = null;
- if ((ushort)Kernel32.GetSystemDefaultLCID() == 0x0011)
+ if ((ushort)PInvoke.GetSystemDefaultLCID() == 0x0011)
{
// Always return DefaultFont for Japanese cultures.
dialogFont = DefaultFont;
diff --git a/src/System.Drawing.Common/src/misc/DpiHelper.cs b/src/System.Drawing.Common/src/misc/DpiHelper.cs
index f35e08f379c..39f7c06b946 100644
--- a/src/System.Drawing.Common/src/misc/DpiHelper.cs
+++ b/src/System.Drawing.Common/src/misc/DpiHelper.cs
@@ -34,13 +34,11 @@ private static void Initialize()
return;
}
- IntPtr hDC = Interop.User32.GetDC(IntPtr.Zero);
- if (hDC != IntPtr.Zero)
+ using var dc = GetDcScope.ScreenDC;
+ if (!dc.IsNull)
{
- s_deviceDpiX = Interop.Gdi32.GetDeviceCaps(hDC, Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- s_deviceDpiY = Interop.Gdi32.GetDeviceCaps(hDC, Interop.Gdi32.DeviceCapability.LOGPIXELSY);
-
- Interop.User32.ReleaseDC(IntPtr.Zero, hDC);
+ s_deviceDpiX = Interop.Gdi32.GetDeviceCaps(dc, Interop.Gdi32.DeviceCapability.LOGPIXELSX);
+ s_deviceDpiY = Interop.Gdi32.GetDeviceCaps(dc, Interop.Gdi32.DeviceCapability.LOGPIXELSY);
}
s_isInitialized = true;
diff --git a/src/System.Windows.Forms/src/GlobalUsings.cs b/src/System.Windows.Forms/src/GlobalUsings.cs
index 31fb337a417..d3d8eb7b514 100644
--- a/src/System.Windows.Forms/src/GlobalUsings.cs
+++ b/src/System.Windows.Forms/src/GlobalUsings.cs
@@ -12,3 +12,8 @@
global using Windows.Win32.UI.Shell;
global using Windows.Win32.UI.Shell.Common;
global using Windows.Win32.UI.WindowsAndMessaging;
+global using BOOL = Windows.Win32.Foundation.BOOL;
+global using HDC = Windows.Win32.Graphics.Gdi.HDC;
+global using HGLOBAL = Windows.Win32.Foundation.HGLOBAL;
+global using HWND = Windows.Win32.Foundation.HWND;
+global using PCWSTR = Windows.Win32.Foundation.PCWSTR;
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
index 1762887fcfb..b8a5b8c511e 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
@@ -18,6 +18,7 @@
using static Interop;
using ComTypes = System.Runtime.InteropServices.ComTypes;
using Encoding = System.Text.Encoding;
+using HandleRef_HWND = HandleRef;
namespace System.Windows.Forms;
@@ -5514,7 +5515,7 @@ private protected virtual bool FocusInternal()
}
///
- /// Creates a for the given , associating
+ /// Creates a for the given , associating
/// it with the first parent if possible.
///
internal static HandleRef GetHandleRef(HWND hwnd) => new(FromChildHandle(hwnd), hwnd);