예제 #1
0
        public CoolerMasterSDK()
        {
            /// If the environment is x64, then use the dll located in the x64 folder, otherwise, use the dll located in the x86 folder.
            string path = $"{Environment.CurrentDirectory}\\Dlls\\{(Environment.Is64BitProcess ? "x64" : "x86")}\\SDKDLL.dll";

            // Loads the dll
            DllHandler = LoadLibrary(path);

            if (DllHandler == null)
            {
                throw new Exception(Marshal.GetLastWin32Error().ToString());
            }

            keyCallbackEventHandler = new KeyCallbackEventHandler(OnCallback);

            // Initiallize Pointers
            InitializeSDK();
        }
예제 #2
0
 private void InitializeSDK()
 {
     getSDKVersionPointer      = (GetSDKVersionPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetCM_SDK_DllVer"), typeof(GetSDKVersionPointer));
     getNowTimePointer         = (GetNowTimePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetNowTime"), typeof(GetNowTimePointer));
     getCPUUsagePointer        = (GetCPUUsagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetNowCPUUsage"), typeof(GetCPUUsagePointer));
     getRamUsagePointer        = (GetRamUsagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetRamUsage"), typeof(GetRamUsagePointer));
     getVolumePeekPointer      = (GetVolumePeekPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetNowVolumePeekValue"), typeof(GetVolumePeekPointer));
     setControlDevicePointer   = (SetControlDevicePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SetControlDevice"), typeof(SetControlDevicePointer));
     isDevicePluggedPointer    = (IsDevicePluggedPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "IsDevicePlug"), typeof(IsDevicePluggedPointer));
     getDeviceLayoutPointer    = (GetDeviceLayoutPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "GetDeviceLayout"), typeof(GetDeviceLayoutPointer));
     enableLedControlPointer   = (EnableLedControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "EnableLedControl"), typeof(EnableLedControlPointer));
     switchLedEffectPointer    = (SwitchLedEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SwitchLedEffect"), typeof(SwitchLedEffectPointer));
     setFullLedColorPointer    = (SetFullLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SetFullLedColor"), typeof(SetFullLedColorPointer));
     setAllLedColorPointer     = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SetAllLedColor"), typeof(SetAllLedColorPointer));
     setLedColorPointer        = (SetLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SetLedColor"), typeof(SetLedColorPointer));
     enableKeyInterruptPointer = (EnableKeyInterruptPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "EnableKeyInterrupt"), typeof(EnableKeyInterruptPointer));
     setKeyCallBackPointer     = (SetKeyCallBackPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(DllHandler, "SetKeyCallBack"), typeof(SetKeyCallBackPointer));
     keyCallbackEventHandler   = new KeyCallbackEventHandler(OnCallback);
 }