如何设置箱子风扇速度

如何设置箱子风扇速度,第1张

概述如何设置箱子风扇速度

我想创build代码设置机箱风扇的速度,并必须在windows 7上工作。

我尝试使用WMI代码创build器,但我得到错误InvalID object path

using System; using System.Management; using System.windows.Forms; namespace WMISample { public class CallWMIMethod { public static voID Main() { try { ManagementObject classInstance = new ManagementObject("root\CIMV2","Win32_Fan.ReplaceKeyPropery='ReplaceKeyPropertyValue'",null); // Obtain in-parameters for the method ManagementBaSEObject inParams = classInstance.getmethodParameters("SetSpeed"); // Add the input parameters. inParams["DesiredSpeed"] = 600; // Execute the method and obtain the return values. ManagementBaSEObject outParams = classInstance.InvokeMethod("SetSpeed",inParams,null); // List outParams Console.Writeline("Out parameters:"); Console.Writeline("ReturnValue: " + outParams["ReturnValue"]); } catch(ManagementException err) { MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message); } } } }

有没有可能参考案例粉丝。 任何帮助可以赞赏?

如何计算任务pipe理器的内存使用情况?

SavefileDialog阻止可移动驱动器

组类似的任务栏button

在C#中打印后台处理程序API设置标志?

当用户login到windows时,ToolStripbutton从PropertyGrID中消失

你在哪里得到调用PowerWriteACValueIndex时使用的索引值?

驱动器select框与windows窗体中的图标

当有人试图运行我的.net桌面应用程序时,如何强制“运行方式”表单出现?

如何在.NET中侦听windows广播消息?

在ToolStripMenuItem中捕获mouseClick和KeyDown事件

你编译代码是因为它是有效的代码。 它在运行时失败,因为你要求它做非法的事情。 根据MSDN :

SetSpeed未执行。

既然如此,这条线就会失败:

ManagementBaSEObject inParams = classInstance.getmethodParameters("SetSpeed");

如果没有实现 SetSpeed (而不是简单的忽略),你会得到一个异常,试图检索与它有关的参数。 删除Try / Catch来验证发生在哪一行。

制造商可能会有一个允许这样做的工具,但WMI似乎有疑问。 如果你确实找到了这样的工具,你可能想要评估bool属性VariableSpeed来查看是否支持变速。

总结

以上是内存溢出为你收集整理的如何设置箱子风扇速度全部内容,希望文章能够帮你解决如何设置箱子风扇速度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1278883.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存