将风扇转速设置为C#

将风扇转速设置为C#,c#,pinvoke,C#,Pinvoke,我知道以前有人问过这个问题, 但我就是不能让它工作。 我呼吁: using System.Management; using System.Management.Instrumentation; using System.Runtime.InteropServices; 我试过这个(我知道这很可怜,但这是我发现的最好的): 如何通过c#设置计算机的风扇速度?你的PInvoke不应该是这样的吗: [DllImport("Cimwin32.dll")] static extern uint32 S

我知道以前有人问过这个问题, 但我就是不能让它工作。 我呼吁:

using System.Management;
using System.Management.Instrumentation;
using System.Runtime.InteropServices;
我试过这个(我知道这很可怜,但这是我发现的最好的):


如何通过c#设置计算机的风扇速度?

你的PInvoke不应该是这样的吗:

[DllImport("Cimwin32.dll")]
static extern uint32 SetSpeed(in uint64 sp);

private void button1_Click(object sender, EventArgs e)
{
           SetSpeed(300);
}

还有一个C++方法来做。你可以把它放在DLL中,然后从你的C代码中调用它


要设置哪个风扇?大多数电脑都有很多。你为什么要这么做?使用像SpeedFan这样的实用程序不是更容易吗?@DavidHeffernan,很好的观点,我甚至不知道SpeedFan实用程序存在。可能的重复是一个有效的pinvoke声明。但据我所知,这个函数并不存在。我错了吗?我在unit64部分得到一个错误,它说它找不到它的定义。
[DllImport("Cimwin32.dll")]
static extern uint32 SetSpeed(in uint64 sp);

private void button1_Click(object sender, EventArgs e)
{
           SetSpeed(300);
}