retinax
asked on
Device Manager in VB
I want to make Device Manager in VB. I found the similar code in VC++ in the following site
http://www.codeproject.com/system/DevMgr.asp
But I want to develop the same thing in VB
http://www.codeproject.com/system/DevMgr.asp
But I want to develop the same thing in VB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops, sorry, EnumAllDevice function should be
Public Function EnumAllDevices(tv As TreeView)
Dim hDevInfo As Long
Dim gd As Guid
Dim devinfo As SP_DEVINFO_DATA
Dim ifData As SP_DEVICE_INTERFACE_DATA
Dim ifDetails As SP_DEVICE_INTERFACE_DETAIL _DATA
Dim nCount As Long, n As Long
Dim bResult As Boolean
Dim sClass As String, sGUID, sDevice As String
hDevInfo = SetupDiGetClassDevs(ByVal 0&, vbNullString, 0, DIGCF_PRESENT Or DIGCF_PROFILE Or DIGCF_ALLCLASSES)
tv.Nodes.Add , , "Root", Environ$("COMPUTERNAME")
If hDevInfo = INVALID_HANDLE_VALUE Then Exit Function
nCount = 0: bResult = True
devinfo.cbSize = Len(devinfo)
Do While bResult
n = SetupDiEnumDeviceInfo(hDev Info, nCount, devinfo)
bResult = CBool(n)
If bResult Then
sGUID = GetSetupRegSetting(hDevInf o, devinfo, SPDRP_CLASSGUID)
If Not NodeExists(tv, sGUID) Then
sClass = GetSetupRegSetting(hDevInf o, devinfo, SPDRP_CLASS)
tv.Nodes.Add tv.Nodes("Root"), tvwChild, sGUID, sClass
End If
sDevice = GetSetupRegSetting(hDevInf o, devinfo, SPDRP_FRIENDLYNAME)
If sDevice = "" Then sDevice = GetSetupRegSetting(hDevInf o, devinfo, SPDRP_DEVICEDESC)
tv.Nodes.Add tv.Nodes(sGUID), tvwChild, "", sDevice
End If
nCount = nCount + 1
Loop
Call SetupDiDestroyDeviceInfoLi st(hDevInf o)
tv.Nodes("Root").Expanded = True
EnumAllDevices = nCount
End Function
Public Function EnumAllDevices(tv As TreeView)
Dim hDevInfo As Long
Dim gd As Guid
Dim devinfo As SP_DEVINFO_DATA
Dim ifData As SP_DEVICE_INTERFACE_DATA
Dim ifDetails As SP_DEVICE_INTERFACE_DETAIL
Dim nCount As Long, n As Long
Dim bResult As Boolean
Dim sClass As String, sGUID, sDevice As String
hDevInfo = SetupDiGetClassDevs(ByVal 0&, vbNullString, 0, DIGCF_PRESENT Or DIGCF_PROFILE Or DIGCF_ALLCLASSES)
tv.Nodes.Add , , "Root", Environ$("COMPUTERNAME")
If hDevInfo = INVALID_HANDLE_VALUE Then Exit Function
nCount = 0: bResult = True
devinfo.cbSize = Len(devinfo)
Do While bResult
n = SetupDiEnumDeviceInfo(hDev
bResult = CBool(n)
If bResult Then
sGUID = GetSetupRegSetting(hDevInf
If Not NodeExists(tv, sGUID) Then
sClass = GetSetupRegSetting(hDevInf
tv.Nodes.Add tv.Nodes("Root"), tvwChild, sGUID, sClass
End If
sDevice = GetSetupRegSetting(hDevInf
If sDevice = "" Then sDevice = GetSetupRegSetting(hDevInf
tv.Nodes.Add tv.Nodes(sGUID), tvwChild, "", sDevice
End If
nCount = nCount + 1
Loop
Call SetupDiDestroyDeviceInfoLi
tv.Nodes("Root").Expanded = True
EnumAllDevices = nCount
End Function
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
I've got quite a few examples in VB.Net (but I assume you're asking for VB6?)