public static bool Init() { // Handle the case when the library is already loaded. if (_dllHandle != IntPtr.Zero) { return(true); } _dllHandle = LoadLibraryEx(DllPath, IntPtr.Zero, 0); if (_dllHandle == IntPtr.Zero) { return(false); } /* * var initAddress = GetProcAddress(_dllHandle, "LogiLedInit"); * if (initAddress == IntPtr.Zero) * { * Shutdown(); * return false; * } * * if (!success) * { * Shutdown(); * } */ var CorsairSetLedsColorsAddr = GetProcAddress(_dllHandle, "CorsairSetLedsColors"); if (CorsairSetLedsColorsAddr == IntPtr.Zero) { Shutdown(); return(false); } _CorsairSetLedsColors = (CorsairLedSetLedsColors)Marshal.GetDelegateForFunctionPointer(CorsairSetLedsColorsAddr, typeof(CorsairLedSetLedsColors)); if (_CorsairSetLedsColors == null) { Shutdown(); return(false); } return(true); }
public static void Shutdown() { if (_dllHandle != IntPtr.Zero) { //_shutdown?.Invoke(); //_shutdown = null; //_setTargetDevice = null; _CorsairSetLedsColors = null; // _setLightingForKeyName = null; FreeLibrary(_dllHandle); _dllHandle = IntPtr.Zero; } }