检测应用程序是否在笔记本电脑上运行 [英] Detect if application is running on laptop
问题描述
可能重复:
如何判断用户是否使用笔记本电脑
我试图找出应用程序是在笔记本电脑还是桌面上运行,有关如何实现这一点的任何想法?
注意:我只对使用Delphi和/或C ++编写的API感兴趣。
编辑:我的目标平台是Windows XP +,甚至Windows 7感谢您的帮助,我已经创建了一个带有助手方法的单元(在Delphi中),感觉自由翻译成C ++或其他语言和/或帮助扩展(或修复可能的缺陷)。
该单位可以在这里找到 http://www.delphigeist .com / 2011/02 / laptop-specific-functions.html
使用此结构体: SYSTEM_POWER_STATUS
,并检查 ACLineStatus
字段的值。
- ACLineStatus = 0 =>系统不使用交流电源>笔记本电脑电池
- ACLineStatus = 1 =>系统使用AC电源=>笔记本电脑+ AC
- ACLineStatus = 255 =>交流电源状态未知=>桌面
免责声明:尝试尝试这些。我不是声称他们是否可靠。但是他们几乎正确。
-
编辑: p>
使用 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屋!