如何检索外围设备的状态 [英] How do I retrieve the state of a peripheral

查看:67
本文介绍了如何检索外围设备的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用的系统是Windows XP。



我是试图用C语言中的程序检测设备的状态(例如此设备无法启动(代码 10 )或此设备已停用(代码 22 ))。



我正在使用setupapi获取计算机上所有外围设备的列表。我尝试了使用SPDRP_INSTALL_STATE的SetupDiGetDeviceRegistryProperty函数,但也许我的方法是错误的。



有谁知道如何完成这项工作?任何代码示例都会很棒。



对不起我的英语我有点生疏。

感谢您的帮助。

Hi everyone,

The system I am working on is Windows XP.

I am stuck trying to retrieve the state of a device with a program in C (such as this device cannot start (code 10) or this device is desactivated (code 22)).

I am using the setupapi to get the list of all the peripheral on my computer. I tried the SetupDiGetDeviceRegistryProperty function with SPDRP_INSTALL_STATE but maybe I am doing it the wrong way.

Has anyone an idea on how I can get this done? Any code example would be great.

Sorry about my English I am a bit rusty.
Thank you for your help.

推荐答案

这些链接可以帮助您:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff551967(v=vs.85).aspx [ ^ ]

http ://msdn.microsoft.com/en-us/library/windows/hardware/ff549203(v = vs.85).aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/windows /赫尔德瓦尔e / ff543130(v = vs.85).aspx [ ^ ]
These links may help you:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff551967(v=vs.85).aspx[^]
http://msdn.microsoft.com/en-us/library/windows/hardware/ff549203(v=vs.85).aspx[^]
http://msdn.microsoft.com/en-us/library/windows/hardware/ff543130(v=vs.85).aspx[^]


我终于找到了这个函数,它给了我想要的东西:



I finally find this function that gives me what I wanted:

CM_Get_DevNode_Status(&Status, &Problem, DeviceInfoData.DevInst, 0)





使用函数SetupDiEnumDeviceInfo检索DeviceInfoData.DevInst的位置。



然后可以在变量Problem中读取设备错误代码。



Where DeviceInfoData.DevInst is retrieved by using the function SetupDiEnumDeviceInfo.

The device error code can then be read in the variable Problem.


这篇关于如何检索外围设备的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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