S
Steve
Hi all,
I am having difficulty getting information from the system on USB devices
attached. The following is a snippet of the code:
Function declarations
Public Declare Function SetupDiGetClassDevs Lib "setupapi.dll" _
Alias "SetupDiGetClassDevsA" ( _
ByRef ClassGuid As Guid, _
ByVal Enumerator As String, _
ByVal hwndParent As Long, _
ByVal flags As Long) As Long
Public Declare Function SetupDiEnumDeviceInfo Lib "setupapi.dll" ( _
ByVal DeviceInfoSet As Long, _
ByVal MemberIndex As Long, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Long
Part of the code:
Dim GUID_DEV_USB As Guid
Dim DevInfo As SP_DEVINFO_DATA
ReDim GUID_DEV_USB.data4(7)
With GUID_DEV_USB ' USB GUID
.Data1 = &HA5DCBF10
.Data2 = &H6530
.Data3 = &H11D2
.data4(0) = &H90
.data4(1) = &H1F
.data4(2) = &H0
.data4(3) = &HC0
.data4(4) = &H4F
.data4(5) = &HB9
.data4(6) = &H51
.data4(7) = &HED
End With
' Get device list
hDevInfo = SetupDiGetClassDevs(GUID_DEVCLASS_USB, vbNullString, vbNull,
DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)
DevInfo.cbSize = Len(DevInfo)
' Enumerate the devices attached
SetupDiEnumDeviceInfo(hDevInfo, I, DevInfo)
this snippet is part of a loop, I starts at 0
Here is the problem. hDevInfo returns an error. Well, not an error as
such, but a handle with the value of 9222812402617788072 (!).
The above code works in C, so why not VB .NET??
Many thanks,
Steve.
I am having difficulty getting information from the system on USB devices
attached. The following is a snippet of the code:
Function declarations
Public Declare Function SetupDiGetClassDevs Lib "setupapi.dll" _
Alias "SetupDiGetClassDevsA" ( _
ByRef ClassGuid As Guid, _
ByVal Enumerator As String, _
ByVal hwndParent As Long, _
ByVal flags As Long) As Long
Public Declare Function SetupDiEnumDeviceInfo Lib "setupapi.dll" ( _
ByVal DeviceInfoSet As Long, _
ByVal MemberIndex As Long, _
ByRef DeviceInfoData As SP_DEVINFO_DATA) As Long
Part of the code:
Dim GUID_DEV_USB As Guid
Dim DevInfo As SP_DEVINFO_DATA
ReDim GUID_DEV_USB.data4(7)
With GUID_DEV_USB ' USB GUID
.Data1 = &HA5DCBF10
.Data2 = &H6530
.Data3 = &H11D2
.data4(0) = &H90
.data4(1) = &H1F
.data4(2) = &H0
.data4(3) = &HC0
.data4(4) = &H4F
.data4(5) = &HB9
.data4(6) = &H51
.data4(7) = &HED
End With
' Get device list
hDevInfo = SetupDiGetClassDevs(GUID_DEVCLASS_USB, vbNullString, vbNull,
DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE)
DevInfo.cbSize = Len(DevInfo)
' Enumerate the devices attached
SetupDiEnumDeviceInfo(hDevInfo, I, DevInfo)
this snippet is part of a loop, I starts at 0
Here is the problem. hDevInfo returns an error. Well, not an error as
such, but a handle with the value of 9222812402617788072 (!).
The above code works in C, so why not VB .NET??
Many thanks,
Steve.