Пример #1
0
        private static void GetDelegate <T>(string entryPoint, out T newDelegate)
            where T : class
        {
            DllImportAttribute attribute = new DllImportAttribute(dllName);

            attribute.CallingConvention = CallingConvention.Cdecl;
            attribute.PreserveSig       = true;
            attribute.EntryPoint        = entryPoint;
            PInvokeDelegateFactory.CreateDelegate(attribute, out newDelegate);
        }
Пример #2
0
        static NVAPI()
        {
            DllImportAttribute attribute = new DllImportAttribute(GetDllName());

            attribute.CallingConvention = CallingConvention.Cdecl;
            attribute.PreserveSig       = true;
            attribute.EntryPoint        = "nvapi_QueryInterface";
            PInvokeDelegateFactory.CreateDelegate(attribute, out nvapi_QueryInterface);

            try
            {
                GetDelegate(0x0150E828, out NvAPI_Initialize);
            }
            catch (DllNotFoundException) { return; }
            catch (EntryPointNotFoundException) { return; }
            catch (ArgumentNullException) { return; }

            if (NvAPI_Initialize() == NvStatus.OK)
            {
                GetDelegate(0xE3640A56, out NvAPI_GPU_GetThermalSettings);
                GetDelegate(0xCEEE8E9F, out _NvAPI_GPU_GetFullName);
                GetDelegate(0x9ABDD40D, out NvAPI_EnumNvidiaDisplayHandle);
                GetDelegate(0x34EF9506, out NvAPI_GetPhysicalGPUsFromDisplay);
                GetDelegate(0xE5AC921F, out NvAPI_EnumPhysicalGPUs);
                GetDelegate(0x5F608315, out NvAPI_GPU_GetTachReading);
                GetDelegate(0x1BD69F49, out NvAPI_GPU_GetAllClocks);
                GetDelegate(0x60DED2ED, out NvAPI_GPU_GetPStates);
                GetDelegate(0x189A1FDF, out NvAPI_GPU_GetUsages);
                GetDelegate(0xDA141340, out NvAPI_GPU_GetCoolerSettings);
                GetDelegate(0x891FA0AE, out NvAPI_GPU_SetCoolerLevels);
                GetDelegate(0x774AA982, out NvAPI_GPU_GetMemoryInfo);
                GetDelegate(0xF951A4D1, out NvAPI_GetDisplayDriverVersion);
                GetDelegate(0x01053FA5, out _NvAPI_GetInterfaceVersionString);
                GetDelegate(0x2DDFB66E, out NvAPI_GPU_GetPCIIdentifiers);
                GetDelegate(0x2A0A350F, out NvAPI_GPU_GetBusSlotId);
                GetDelegate(0x1BE0B8E5, out NvAPI_GPU_GetBusId);

                available = true;
            }
        }