Using SetupDiGetDeviceRegistryProperty to get device type

Hi All,

I am trying to retrieve the device type for the USB memory stick by using the funciton
SetupDiGetDeviceRegistryProperty.
Before this I use the follwing APIs to get the Device Info Data(to be used in this API).

  1. Call to SetupDiGetClassDevs which gives the handle to device info set.
  2. Call to SetupDiEnumDeviceInterfaces and along with this I call
    SetupDiGetDeviceInterfaceDetail to get the device info data.

Then I use it in the call to SetupDiGetDeviceRegistryProperty:
SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data, SPDRP_CAPABILITIES , &PropertyRegDataType, NULL, 0, &RequiredSize);
PropertyBuffer = (BYTE*)malloc(RequiredSize);
if(!SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data, SPDRP_CAPABILITIES , &PropertyRegDataType, PropertyBuffer, RequiredSize, &RequiredSize));

But it still fails and the error code is 13, i.e. ERROR_INVALID_DATA.
Can you please throw some light as to why this thing is happening.

Thanks
Pankaj


Yahoo! India Answers: Share what you know. Learn something new Click here
Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now

Many of the SetupDi* calls require that “output” structures (structures
that the SetupDi* function are returning to you, the caller) be
*partially* initialized. Usually this just means that the cbSize field
must be initialized to sizeof(SP_WHATEVER_STRUCT).

If that is not the problem, then please state exactly which API call is
failing.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pankaj Adlakha
Sent: Wednesday, May 31, 2006 5:06 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Using SetupDiGetDeviceRegistryProperty to get device
type

Hi All,

I am trying to retrieve the device type for the USB memory stick by
using the funciton
SetupDiGetDeviceRegistryProperty.
Before this I use the follwing APIs to get the Device Info Data(to be
used in this API).

  1. Call to SetupDiGetClassDevs which gives the handle to device info
    set.
  2. Call to SetupDiEnumDeviceInterfaces and along with this I call
    SetupDiGetDeviceInterfaceDetail to get the device info data.

Then I use it in the call to SetupDiGetDeviceRegistryProperty:
SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data,
SPDRP_CAPABILITIES , &PropertyRegDataType, NULL, 0, &RequiredSize);
PropertyBuffer = (BYTE*)malloc(RequiredSize);
if(!SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data,
SPDRP_CAPABILITIES , &PropertyRegDataType, PropertyBuffer, RequiredSize,
&RequiredSize));

But it still fails and the error code is 13, i.e. ERROR_INVALID_DATA.
Can you please throw some light as to why this thing is happening.

Thanks
Pankaj


Yahoo! India Answers: Share what you know. Learn something new Click
here
http:o.com/>
Send free SMS to your Friends on Mobile from your Yahoo! Messenger
Download now
http:load.php> — Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</http:></http:>

Check the example of enumdisk in DDK.

On 5/31/06, Pankaj Adlakha wrote:
>
> Hi All,
>
> I am trying to retrieve the device type for the USB memory stick by using
> the funciton
> SetupDiGetDeviceRegistryProperty.
> Before this I use the follwing APIs to get the Device Info Data(to be used
> in this API).
> 1. Call to SetupDiGetClassDevs which gives the handle to device info set.
> 2. Call to SetupDiEnumDeviceInterfaces and along with this I call
> SetupDiGetDeviceInterfaceDetail to get the device info data.
>
> Then I use it in the call to SetupDiGetDeviceRegistryProperty:
> SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data,
> SPDRP_CAPABILITIES , &PropertyRegDataType, NULL, 0, &RequiredSize);
> PropertyBuffer = (BYTE*)malloc(RequiredSize);
> if(!SetupDiGetDeviceRegistryProperty(hDevInfo, &dev_info_data,
> SPDRP_CAPABILITIES , &PropertyRegDataType, PropertyBuffer, RequiredSize,
> &RequiredSize));
> But it still fails and the error code is 13, i.e. ERROR_INVALID_DATA.
> Can you please throw some light as to why this thing is happening.
>
> Thanks
> Pankaj
>
> ------------------------------
> Yahoo! India Answers: Share what you know. Learn something new Click herehttp:</http:>
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download
> nowhttp:— Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List
> Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
></http:>