7

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#?

bmargulies
  • 97,814
  • 39
  • 186
  • 310
funerr
  • 7,212
  • 14
  • 81
  • 129
  • 1
    Which fan do you want to set? Most computers have lots of them. And why do you want to do this? Wouldn't it be much easier to use a utility like SpeedFan? – David Heffernan May 18 '12 at 15:37
  • @DavidHeffernan, good points, And I didn't know that SpeedFan Utility even existed. – funerr May 18 '12 at 16:09
  • possible duplicate of [C# control FAN speed](http://stackoverflow.com/questions/9391181/c-sharp-control-fan-speed) – David Heffernan May 18 '12 at 16:49

1 Answers1

3

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?

Community
  • 1
  • 1
Samy Arous
  • 6,794
  • 13
  • 20