Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Fan Speed in C#

Tags:

c#

pinvoke

I know this has been asked before, but I just can't seem to get it working. I have called the following:

using System.Management;
using System.Management.Instrumentation;
using System.Runtime.InteropServices;

And I have tried this (I know it's pathetic, but its the best I found):

  [DllImport("Cimwin32.dll")]
        private void button1_Click(object sender, EventArgs e)
        {
            uint32 SetSpeed( //???
              [in]  uint64 300
            );
        }

How can I set the computer's fan speed via c#?

like image 921
funerr Avatar asked May 18 '12 15:05

funerr


1 Answers

Shouldn't your PInvoke be something like that:

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

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

Also here's a C++ method to do so. You could put that in a DLL and call it from your C# code

How can I control my PC's fan speed using C++ in Vista?

like image 195
Samy Arous Avatar answered Sep 23 '22 10:09

Samy Arous