Skip to content

Commit 8eadd32

Browse files
authored
Merge pull request #433 from Aytackydln/marshal-get-last-system-error
Replace Marshal.GetLastWin32Error() with Marshal.GetLastSystemError()
2 parents 13f3dde + 00eec7a commit 8eadd32

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static void LoadCMSDK()
4747
#if NET6_0
4848
if (_handle == IntPtr.Zero) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4949
#else
50-
if (_handle == 0) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
50+
if (_handle == 0) throw new RGBDeviceException($"CoolerMaster LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
5151
#endif
5252

5353
_getSDKVersionPointer = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_handle, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));

RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static void LoadCUESDK()
4040
#if NET6_0
4141
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4242
#else
43-
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
43+
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
4444
#endif
4545

4646
if (!NativeLibrary.TryGetExport(_handle, "CorsairSetLedsColorsBufferByDeviceIndex", out _corsairSetLedsColorsBufferByDeviceIndexPointer)) throw new RGBDeviceException("Failed to load Corsair function 'CorsairSetLedsColorsBufferByDeviceIndex'");

RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private static void LoadLogitechGSDK()
4141
#if NET6_0
4242
throw new RGBDeviceException($"Logitech LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4343
#else
44-
throw new RGBDeviceException($"Logitech LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
44+
throw new RGBDeviceException($"Logitech LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
4545
#endif
4646

4747
if (!NativeLibrary.TryGetExport(_handle, "LogiLedInit", out _logiLedInitPointer)) throw new RGBDeviceException("Failed to load Logitech function 'LogiLedInit'");

RGB.NET.Devices.Msi/Native/_MsiSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private static void LoadMsiSDK()
4242
#if NET6_0
4343
throw new RGBDeviceException($"MSI LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4444
#else
45-
throw new RGBDeviceException($"MSI LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
45+
throw new RGBDeviceException($"MSI LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
4646
#endif
4747

4848
_initializePointer = (InitializePointer)Marshal.GetDelegateForFunctionPointer(NativeLibrary.GetExport(_handle, "MLAPI_Initialize"), typeof(InitializePointer));

RGB.NET.Devices.Razer/Native/_RazerSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static void LoadRazerSDK()
4040
#if NET6_0
4141
throw new RGBDeviceException($"Razer LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4242
#else
43-
throw new RGBDeviceException($"Razer LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
43+
throw new RGBDeviceException($"Razer LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
4444
#endif
4545

4646
if (!NativeLibrary.TryGetExport(_handle, "Init", out _initPointer)) throw new RGBDeviceException("Failed to load Razer function 'Init'");

RGB.NET.Devices.Wooting/Native/_WootingSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static void LoadWootingSDK()
4040
#if NET6_0
4141
throw new RGBDeviceException($"Wooting LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
4242
#else
43-
throw new RGBDeviceException($"Wooting LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
43+
throw new RGBDeviceException($"Wooting LoadLibrary failed with error code {Marshal.GetLastSystemError()}");
4444
#endif
4545

4646
if (!NativeLibrary.TryGetExport(_handle, "wooting_rgb_device_info", out _getDeviceInfoPointer)) throw new RGBDeviceException("Failed to load wooting function 'wooting_rgb_device_info'");

0 commit comments

Comments
 (0)