pcGetDeviceProperty 函数 (portcls.h)

PcGetDeviceProperty 函数从注册表返回请求的设备属性。

语法

PORTCLASSAPI NTSTATUS PcGetDeviceProperty(
  [in]  PVOID                    DeviceObject,
  [in]  DEVICE_REGISTRY_PROPERTY DeviceProperty,
  [in]  ULONG                    BufferLength,
  [out] PVOID                    PropertyBuffer,
  [out] PULONG                   ResultLength
);

参数

[in] DeviceObject

指向设备的设备对象的指针。 此参数指向 DEVICE_OBJECT 系统结构,但转换为 PVOID 类型。

[in] DeviceProperty

指定请求即插即用设备属性。 有关属性说明符值的列表,请参阅以下“备注”部分。

[in] BufferLength

指定用于接收所请求属性数据的缓冲区的长度(以字节为单位)。

[out] PropertyBuffer

指向调用方分配的缓冲区的指针,方法要在其中写入请求的属性数据。 缓冲区必须足够大,才能包含 BufferLength 中指定的字节数。

[out] ResultLength

指向调用方分配的变量的指针,方法在该变量中输出一个计数,指定实际写入缓冲区的字节数。 如果 BufferLength 中指定的缓冲区大小太小而无法保存属性数据,则 该方法将改为输出属性数据所需的字节数并返回STATUS_BUFFER_TOO_SMALL。

返回值

如果调用成功,PcGetDeviceProperty 将返回STATUS_SUCCESS。 否则,它将返回相应的错误代码。 如果 BufferLength 中指定的缓冲区大小不足以包含请求的属性数据,则例程返回STATUS_BUFFER_TOO_SMALL。

注解

DeviceProperty 参数设置为头文件 wdm.h 中的以下DEVICE_REGISTRY_PROPERTY枚举值之一:

DevicePropertyAddress

DevicePropertyBootConfiguration

DevicePropertyBootConfigurationTranslated

DevicePropertyBusNumber

DevicePropertyBusTypeGuid

DevicePropertyClassGuid

DevicePropertyClassName

DevicePropertyCompatibleIDs

DevicePropertyDetachability

DevicePropertyDeviceDescription

DevicePropertyDriverKeyName

DevicePropertyEnumeratorName

DevicePropertyFriendlyName

DevicePropertyHardwareID

DevicePropertyInstallState

DevicePropertyLegacyBusType

DevicePropertyLocationInformation

DevicePropertyManufacturer

DevicePropertyPhysicalDeviceObjectName

DevicePropertyUINumber

有关上述 DevicePropertyXxx 值的说明,请参阅 IoGetDeviceProperty

可能需要对 PcGetDeviceProperty 进行两次调用才能确定所需的 BufferLength。 在第一次调用中, BufferLength 可以是零,也可以是所需缓冲区大小的最佳猜测估计值。 如果返回状态为STATUS_BUFFER_TOO_SMALL,这意味着调用方应分配通过 ResultLength 输出的大小的缓冲区,并再次调用 PcGetDeviceProperty

要求

要求
最低受支持的客户端 PortCls 系统驱动程序在 Microsoft Windows 98/Me 和 Windows 2000 及更高版本的操作系统中实现 PcGetDeviceProperty 函数。
目标平台 通用
标头 portcls.h (包括 Portcls.h)
Library Portcls.lib
IRQL PASSIVE_LEVEL

另请参阅

DEVICE_OBJECT

IoGetDeviceProperty