From 00d20db280ffdeb03801bf21981675d26fc2739a Mon Sep 17 00:00:00 2001 From: SadPencil Date: Tue, 10 Sep 2024 13:12:19 +0800 Subject: [PATCH] Refactor NativeConstants and NativeMethods --- Mo3RegUI/Mo3RegUI.csproj | 1 + Mo3RegUI/NativeConstants.cs | 11 +++++++++++ Mo3RegUI/NativeMethods.cs | 30 +++--------------------------- 3 files changed, 15 insertions(+), 27 deletions(-) create mode 100644 Mo3RegUI/NativeConstants.cs diff --git a/Mo3RegUI/Mo3RegUI.csproj b/Mo3RegUI/Mo3RegUI.csproj index b324029..df01032 100644 --- a/Mo3RegUI/Mo3RegUI.csproj +++ b/Mo3RegUI/Mo3RegUI.csproj @@ -77,6 +77,7 @@ + diff --git a/Mo3RegUI/NativeConstants.cs b/Mo3RegUI/NativeConstants.cs new file mode 100644 index 0000000..96ea744 --- /dev/null +++ b/Mo3RegUI/NativeConstants.cs @@ -0,0 +1,11 @@ +namespace Mo3RegUI +{ + public class NativeConstants + { + /// SM_CXSCREEN -> 0 + public const int SM_CXSCREEN = 0; + + /// SM_CYSCREEN -> 1 + public const int SM_CYSCREEN = 1; + } +} diff --git a/Mo3RegUI/NativeMethods.cs b/Mo3RegUI/NativeMethods.cs index 8a81a3f..61ab75d 100644 --- a/Mo3RegUI/NativeMethods.cs +++ b/Mo3RegUI/NativeMethods.cs @@ -1,42 +1,18 @@ namespace Mo3RegUI { - public partial class NativeMethods { /// Return Type: int ///nIndex: int - [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetSystemMetrics")] + [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetSystemMetrics")] public static extern int GetSystemMetrics(int nIndex); - } - - public partial class NativeConstants - { - /// SM_CXSCREEN -> 0 - public const int SM_CXSCREEN = 0; - } - - public partial class NativeConstants - { - /// SM_CYSCREEN -> 1 - public const int SM_CYSCREEN = 1; - } - - public partial class NativeMethods - { /// Return Type: UINT->unsigned int - [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GetACP")] + [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "GetACP")] public static extern uint GetACP(); - } - - public partial class NativeMethods - { - /// Return Type: UINT->unsigned int - [System.Runtime.InteropServices.DllImportAttribute("winmm.dll", EntryPoint = "waveOutGetNumDevs")] + [System.Runtime.InteropServices.DllImport("winmm.dll", EntryPoint = "waveOutGetNumDevs")] public static extern uint waveOutGetNumDevs(); - } - }