2012-05-18 88 views
7

我知道這已被問過, ,但我似乎無法得到它的工作。 我已經叫了以下內容:設置風扇速度在C#

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

我曾經嘗試這樣做(我知道這是可悲的,但它的最好的,我發現):

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

如何通過C#設置計算機的風扇轉速?

+1

你想要哪個風扇設置打電話了嗎?大多數電腦有很多。你爲什麼想這樣做?使用SpeedFan這樣的實用程序會不會更容易? –

+0

@DavidHeffernan,好點,我不知道SpeedFan Utility甚至存在。 – funerr

+0

[C#control FAN speed]的可能重複(http://stackoverflow.com/questions/9391181/c-sharp-control-fan-speed) –

回答

2

應該不是你的PInvoke是類似的東西:

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

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

而且,這裏是一個C++的方法來做到這一點。你可以把在一個DLL,並從你的C#代碼

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

+0

這是一個有效的pinvoke聲明。但據我所知,這個功能並不存在。我錯了嗎? –

+1

我在unit64部分出現錯誤,它說它無法找到它的定義。 – funerr