[DllImport("setupapi.dll", SetLastError=true)]
static extern void CM_Get_DevNode_Status(ref UInt32 status, ref UInt32 probNum, IntPtr devInst, int flags);
<DllImport("cfgmgr32.dll", SetLastError:=True, CharSet:=CharSet.Unicode)> _
Private Shared Function CM_Get_DevNode_Status(ByRef status As ULong, ByRef probNum As ULong, ByVal devInst As IntPtr, ByVal Flag As Integer) As Integer
End Function
None.
Do you know one? Please contribute it!
None.
Please add some!
If CM_Get_DevNode_Status(status, problem, DeviceInfoData.DevInst, 0) = CR_SUCCESS Then
Dim sbDesc As New StringBuilder("")
Dim MAX_LEN As Integer = 512
Dim propRegDataType As Integer = 0
sbDesc.Capacity = MAX_LEN
Dim reqSize As Integer = 0
SetupDiGetDeviceRegistryProperty(NewDeviceInfoSet, DeviceInfoData, DirectCast(SPDRP_FRIENDLYNAME, Integer), propRegDataType, sbDesc, MAX_LEN, reqSize)
If sbDesc.ToString() = "" Then
SetupDiGetDeviceRegistryProperty(NewDeviceInfoSet, DeviceInfoData, DirectCast(SPDRP_DEVICEDESC, Integer), propRegDataType, sbDesc, MAX_LEN, reqSize)
End If
If sbDesc.ToString() = "" Then
sbDesc.Append("Unknown Description")
End If
Dim sbHWID As New StringBuilder("")
sbHWID.Capacity = MAX_LEN
SetupDiGetDeviceRegistryProperty(NewDeviceInfoSet, DeviceInfoData, DirectCast(SPDRP_HARDWAREID, Integer), propRegDataType, sbHWID, MAX_LEN, reqSize)
Dim scanResult As New ScanResults(sbHWID.ToString(), sbDesc.ToString())
Console.WriteLine("Device Detected: {0} - {1}", sbDesc.ToString(), sbHWID.ToString())
Dim deviceInstallParams As New SP_DEVINSTALL_PARAMS()
deviceInstallParams.cbSize = Marshal.SizeOf(GetType(SP_DEVINSTALL_PARAMS))
SetupDiGetDeviceInstallParams(NewDeviceInfoSet, DeviceInfoData, deviceInstallParams)
deviceInstallParams.DriverPath = "D:\STK1160_AVStream_ATV_20070831"
If Not SetupDiBuildDriverInfoList(NewDeviceInfoSet, DeviceInfoData, SPDIT_COMPATDRIVER) Then
Dim eCode As Integer = Marshal.GetLastWin32Error()
Console.WriteLine(vbTab & "Error Building Driver Info List. Code: {0}", eCode)
End If
Dim memIndex As Integer = 0
Dim drvErr As Integer = 0
Dim drvData As New SP_DRVINFO_DATA()
drvData.cbSize = Marshal.SizeOf(GetType(SP_DRVINFO_DATA))
Dim enumResult As Boolean = SetupDiEnumDriverInfo(NewDeviceInfoSet, DeviceInfoData, SPDIT_COMPATDRIVER, memIndex, drvData)
If Not enumResult Then
drvErr = Marshal.GetLastWin32Error()
Console.WriteLine(vbTab & "Error Enumerating Driver Info. Code: {0}", drvErr)
End If
'While enumResult AndAlso drvErr <> ERROR_NO_MORE_ITEMS
' System.Math.Max(System.Threading.Interlocked.Increment(memIndex), memIndex - 1)
' End While
SetupDiDestroyDriverInfoList(NewDeviceInfoSet, DeviceInfoData, SPDIT_COMPATDRIVER)
End If