Click here to Skip to main content
15,887,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all.

I've got a problem while working with SetupApi calls.
I need to retrieve a device type from a device.


The I used to get it:
VB
    <DllImport("setupapi.dll", SetLastError:=True)> _
    Public Shared Function SetupDiGetDeviceRegistryProperty( _
        ByVal DeviceInfoSet As IntPtr, _
        ByRef DeviceInfoData As SP_DEVINFO_DATA, _
        ByVal [Property] As Win32.SetupDiGetDeviceRegistryPropertyEnum, _
        ByRef PropertyRegDataType As Integer, _
        ByRef PropertyBuffer As Integer, _
        ByVal PropertyBufferSize As Integer, _
        ByRef RequiredSize As Integer) As Boolean
    End Function

''' some code here


Dim result As Int32
 Dim RequiredSize As Integer
 Dim DataType As Integer = 4
 Dim returnVal As Boolean = Win32.SetupDiGetDeviceRegistryProperty(hDevInfo, DevInfoData, Win32.SetupDiGetDeviceRegistryPropertyEnum.SPDRP_DEVTYPE, _
                                                                    DataType, result, 4, RequiredSize)

But returnVal is always FALSE, and I'm getting an win32error 13 (ERROR_INVALID_DATA).
I don't know what I am doing wrong, because I can get other properties.


Suggestions??

Thanks
Posted
Updated 23-Jan-12 8:43am
v2

1 solution

OK I found other way to do it.
Actually, I was not trying to know a "devicetype" but I want to know if it is removable.

I use DeviceIoControl and IOCTL_STORAGE_GET_HOTPLUG_INFO.


Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900