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。

備註

從頭文件 wdm.h 將 DeviceProperty 參數設定為下列其中一個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 函式。
目標平台 Universal
標頭 portcls.h (包含 Portcls.h)
程式庫 Portcls.lib
IRQL PASSIVE_LEVEL

另請參閱

DEVICE_OBJECT

IoGetDeviceProperty