The SetupDiGetDeviceProperty function retrieves a device instance property.
WINSETUPAPI BOOL SetupDiGetDevicePropertyW( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize, DWORD Flags );
A handle to a device information set that contains a device instance for which to retrieve a device instance property.
A pointer to the SP_DEVINFO_DATA structure that represents the device instance for which to retrieve a device instance property.
A pointer to a DEVPROPKEY structure that represents the device property key of the requested device instance property.
A pointer to a DEVPROPTYPE-typed variable that receives the property-data-type identifier of the requested device instance property, where the property-data-type identifier is the bitwise OR between a base-data-type identifier and, if the base-data type is modified, a property-data-type modifier.
A pointer to a buffer that receives the requested device instance property. SetupDiGetDeviceProperty retrieves the requested property only if the buffer is large enough to hold all the property value data. The pointer can be NULL. If the pointer is set to NULL and RequiredSize is supplied, SetupDiGetDeviceProperty returns the size of the property, in bytes, in *RequiredSize.
The size, in bytes, of the PropertyBuffer buffer. If PropertyBuffer is set to NULL, PropertyBufferSize must be set to zero.
A pointer to a DWORD-typed variable that receives the size, in bytes, of either the device instance property if the property is retrieved or the required buffer size if the buffer is not large enough. This pointer can be set to NULL.
This parameter must be set to zero.
SetupDiGetDeviceProperty returns TRUE if it is successful. Otherwise, it returns FALSE, and the logged error can be retrieved by calling GetLastError.
The following table includes some of the more common error codes that this function might log.
||The value of Flags is not zero.|
||The device information set that is specified by DevInfoSet is not valid.|
||A supplied parameter is not valid. One possibility is that the device information element is not valid.|
||The property key that is supplied by PropertyKey is not valid.|
||An unspecified internal data value was not valid.|
||A user buffer is not valid. One possibility is that PropertyBuffer is NULL and PropertBufferSize is not zero.|
||The device instance that is specified by DevInfoData does not exist.|
||The PropertyBuffer buffer is too small to hold the requested property value, or an internal data buffer that was passed to a system call was too small.|
||There was not enough system memory available to complete the operation.|
||The requested device property does not exist.|
||The caller does not have Administrator privileges.|
SetupDiGetDeviceProperty is part of the unified device property model.
SetupAPI supports only a Unicode version of SetupDiGetDeviceProperty.
To obtain the device property keys that represent the device properties that are set for a device instance, call SetupDiGetDevicePropertyKeys.
To set a device instance property, call SetupDiSetDeviceProperty.
|Windows version||Available in Windows Vista and later versions of Windows.|
|Target Platform||DesktopFor universal, call CM_Get_DevNode_Property|
|Header||setupapi.h (include SetupAPI.h)|