检测应用程序是否在笔记本电脑上运行 [英] Detect if application is running on laptop

查看:159
本文介绍了检测应用程序是否在笔记本电脑上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:


我想知道应用程序是在笔记本电脑还是桌面上运行,有关如何实现这一点的任何想法吗?



注意:我只对用Delphi和/或C ++编写的API感兴趣。



编辑:我的目标平台是Windows XP +

最后编辑:感谢大家的帮助,我已经创建了一个带有帮助方法的单元(在Delphi中)翻译为C ++或其他语言和/或帮助扩展(或修复可能的缺陷)。
该单位可以在这里找到
http://www.delphigeist .com / 2011/02 / laptop-specific-functions.html

解决方案

使用此结构: SYSTEM_POWER_STATUS ,并检查 ACLineStatus 字段的值。




  • ACLineStatus = 0 =>系统未使用交流电源>笔记本电脑+电池

  • ACLineStatus = 1 =>系统正在使用AC电源=>笔记本电脑+ AC

  • ACLineStatus = 255 =>交流电源状态未知=>桌面



免责声明:尝试尝试这些。我不是声称如果他们是可靠的。



-



编辑:



使用 GetSystemPowerStatus 以获取上述结构的值。



顺便说一下,其他领域的结构;也许你可以找到一些有用的模式,给你不同字段的值的一些组合,以帮助您可靠地检测应用程序是否正在笔记本电脑上运行。


Possible Duplicate:
How can I tell if a user is using a laptop

I'm trying to find out if the application is running on a laptop or on a desktop, any ideas on how to achieve this?

Note: I'm interested only in API's written in Delphi and/or C++.

EDIT: my target platform is Windows XP+, even Windows 7 only is OK.

LAST EDIT: thank you all for your help, I have created a unit with helper methods(In Delphi) feel free to translate to C++ or other languages and/or help extending(or fixing possible flaws). The unit can be found here http://www.delphigeist.com/2011/02/laptop-specific-functions.html

解决方案

Use this struct : SYSTEM_POWER_STATUS, and check the value of ACLineStatus field.

  • ACLineStatus = 0 => The system is not using AC power > Laptop + battery
  • ACLineStatus = 1 => The system is using AC power => Laptop + AC
  • ACLineStatus = 255 => AC power status is unknown => Desktop

Disclaimer : Try experimenting with these. I'm not claiming if they're reliable. But they're almost correct.

--

EDIT:

Use GetSystemPowerStatus to get the value of the above mentioned structure.

By the way, you can also experiment with the other fields of the structure; maybe you can find some useful pattern, giving you some combination of values of different fields to help you reliably detect if application is running on laptop or not.

这篇关于检测应用程序是否在笔记本电脑上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆