How to Control My Pc's Fan Speed Using C++ in Vista

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

ACPI:

You need to learn about and use the WMI - Windows system management interface. Here are a few resources that will give you clues on where to start:

  • SetSpeed Method of the CIM_Fan Class
  • WMI C++ Application Examples
  • Example: Calling a Provider Method

Note that some motherboards don't support fan speed changes, and even those that do may not expose this to the WMI. In the best case you may still have to detect the motherboard type and talk to the fan management controllers directly.

No ACPI:

If you don't want to use ACPI then you're going to have to write your own code to access the SMBUS on the motherboard, and then control the fan controller chips.

Check out the program motherboard monitor for clues on how to get started. It's nontrivial, since every motherboard and bios is different.

open source software to control computer fan speed

lm-sensors provides a fancontrol tool that can change the speed of your fans, along with some nice calibration tools to help you maintain reasonable temperatures with minimum energy and noise. Excellent tools.

Programmatically access CPU fan on a laptop? (Windows)

I am at the moment working on a project that, among other things, controls the computer fans. Basically, the fans are controlled by the superIO chip of your computer. We access the chip directly using port-mapped IO, and from there we can get to the logical fan device. Using port-mapped IO requires the code to run in kernel mode, but windows does not supply any drivers for generic port IO (with good reason, since it is a very powerful tool), so we wrote our own driver, and used that.

If you want to go down this route, you basically need knowledge in two areas: driver development and how to access and interpret superIO chip information. When we started the project, we didn't know anything in either of these areas, so it has been learning by browsing, reading and finally doing. To gain the knowledge, we have been especially helped by looking at these links:

  1. The WDK, which is the Windows Driver Kit. You need this to compile any driver you write for windows, With it comes a whole lot of source code for example drivers, including a driver for general port-mapped IO, called portio.
  2. WinIO has source code for a driver in C, a dll in C that programmatically installs and loads that driver, and some C# code for a GUI, that loads the dll and reads/writes to the ports. The driver is very similar to the one in portio.
  3. lm-sensors is a linux project, that, among other things, detects your superIO chip. /prog/detect/sensors-detect is the perl program, that does the detecting, and we have spent some time going through the code to see how to interface with a superIO chip.
  4. When we were going through the lm-sensors code, it was very nice to have tools like RapidDriver and RW-everything, since they allowed us to simulate a run of sensors-detect. The latter is the more powerful, and is very helpful in visualising the IO space, while the former provides easier access to some operations which map better to the ones in sensors-detect (read/write byte to port)
  5. Finally, you need to find the datasheet of your superIO chip. From the examples, that I have seen, the environment controllers of each chip provide similar functionality (r/w fan speed, read temperature, read chip voltage), but vary in what registers you have to write to in order to get to this functionality. This place has had all the datasheets, we have needed so far.

Set Fan Speed in C#

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?



Related Topics



Leave a reply



Submit