有一个VB的 Option Explicit'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ?1996-2002 VBnet, Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you can not publish ' or reproduce this code on any web site, ' on any online service, or distribute on ' any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'listview column auto-resizing Private Const LVM_FIRST As Long = &H1000 Private Const LVM_SETCOLUMNWIDTH As Long = (LVM_FIRST + 30) Private Const LVSCW_AUTOSIZE As Long = -1 Private Const LVSCW_AUTOSIZE_USEHEADER As Long = -2Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Sub Form_Load() With ListView1 .ListItems.Clear .ColumnHeaders.Clear .View = lvwReport .Sorted = False End With
Command1.Caption = "PointingDevice Info"
End Sub Private Sub Command1_Click() ListView1.ListItems.Clear Call wmiPointingDeviceInfo Call lvAutosizeControl(ListView1)
End Sub Private Sub lvAutosizeControl(lv As ListView) Dim col2adjust As Long 'Size each column based on the maximum of 'wither the ColumnHeader text width, or, 'if the items below it are wider, the 'widest list item in the column lv.Visible = False For col2adjust = 0 To lv.ColumnHeaders.Count - 1
End Sub Private Sub wmiPointingDeviceInfo() Dim wmiObjSet As SWbemObjectSet Dim obj As SWbemObject Dim msg As String Dim thiscol As Long Dim itmx As ListItem On Local Error Resume Next
'add first column and set initial parameters With ListView1 .ListItems.Clear .View = lvwReport .Sorted = False .ColumnHeaders.Clear .ColumnHeaders.Add , , "WMI Property" .ListItems.Add , , "Description" .ListItems.Add , , "Status" .ListItems.Add , , "ConfigManagerErrorCode"
Select Case obj.ConfigManagerErrorCode Case 0: msg = "This device is working properly." Case 1: msg = "This device is not configured correctly." Case 2: msg = "Windows cannot load the driver for this device." Case 3: msg = "The driver might be corrupted, or your system " & _ "may be running low on memory or other resources." Case 4: msg = "This device is not working properly. One of its " & _ "drivers or your registry might be corrupted." Case 5: msg = "The driver for this device needs a resource " & _ "that Windows cannot manage." Case 6: msg = "The boot configuration for this device " & _ "conflicts with other devices." Case 7: msg = "Cannot filter." Case 8: msg = "The driver loader for the device is missing." Case 9: msg = "This device is not working properly because" & _ "the controlling firmware is reporting the " & _ "resources for the device incorrectly." Case 10: msg = "This device cannot start." Case 11: msg = "This device failed." Case 12: msg = "This device cannot find enough free " & _ "resources that it can use." Case 13: msg = "Windows cannot verify this device's resources." Case 14: msg = "This device cannot work properly until " & _ "you restart your computer." Case 15: msg = "This device is not working properly because " & _ "there is probably a re-enumeration problem." Case 16: msg = "Windows cannot identify all the resources this device uses." Case 17: msg = "This device is asking for an unknown resource type." Case 18: msg = "Reinstall the drivers for this device." Case 19: msg = "Failure using the VXD loader." Case 20: msg = "Your registry might be corrupted." Case 21: msg = "System failure: Try changing the driver for this device. " & _ "If that does not work, see your hardware " & _ "documentation. Windows is removing this device." Case 22: msg = "This device is disabled." Case 23: msg = "System failure: Try changing the driver for " & _ "this device. If that doesn't work, see your " & _ "hardware documentation."
不会吧,接上,......................... Case 24: msg = "This device is not present, is not working " & _ "properly, or does not have all its drivers installed." Case 25: msg = "Windows is still setting up this device." Case 26: msg = "Windows is still setting up this device." Case 27: msg = "This device does not have valid log configuration." Case 28: msg = "The drivers for this device are not installed." Case 29: msg = "This device is disabled because the firmware of " & _ "the device did not give it the required resources." Case 30: msg = "This device is using an Interrupt Request (IRQ) " & _ "resource that another device is using." Case 31: msg = "This device is not working properly because Windows " & _ "cannot load the drivers required for this device." End Select
Option Explicit''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ?1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you can not publish
' or reproduce this code on any web site,
' on any online service, or distribute on
' any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'listview column auto-resizing
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_SETCOLUMNWIDTH As Long = (LVM_FIRST + 30)
Private Const LVSCW_AUTOSIZE As Long = -1
Private Const LVSCW_AUTOSIZE_USEHEADER As Long = -2Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Form_Load() With ListView1
.ListItems.Clear
.ColumnHeaders.Clear
.View = lvwReport
.Sorted = False
End With
Command1.Caption = "PointingDevice Info"
End Sub
Private Sub Command1_Click() ListView1.ListItems.Clear
Call wmiPointingDeviceInfo
Call lvAutosizeControl(ListView1)
End Sub
Private Sub lvAutosizeControl(lv As ListView) Dim col2adjust As Long 'Size each column based on the maximum of
'wither the ColumnHeader text width, or,
'if the items below it are wider, the
'widest list item in the column
lv.Visible = False
For col2adjust = 0 To lv.ColumnHeaders.Count - 1
Call SendMessage(lv.hwnd, _
LVM_SETCOLUMNWIDTH, _
col2adjust, _
ByVal LVSCW_AUTOSIZE_USEHEADER) Next
lv.Visible = True
End Sub
Private Sub wmiPointingDeviceInfo() Dim wmiObjSet As SWbemObjectSet
Dim obj As SWbemObject
Dim msg As String
Dim thiscol As Long
Dim itmx As ListItem On Local Error Resume Next
'add first column and set initial parameters
With ListView1
.ListItems.Clear
.View = lvwReport
.Sorted = False
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "WMI Property"
.ListItems.Add , , "Description"
.ListItems.Add , , "Status"
.ListItems.Add , , "ConfigManagerErrorCode"
.ListItems.Add , , "Manufacturer"
.ListItems.Add , , "Name"
.ListItems.Add , , "HardwareType"
.ListItems.Add , , "DeviceInterface"
.ListItems.Add , , "DoubleSpeedThreshold"
.ListItems.Add , , "Handedness"
.ListItems.Add , , "NumberOfButtons"
.ListItems.Add , , "PointingType"
.ListItems.Add , , "QuadSpeedThreshold"
.ListItems.Add , , "DeviceID"
.ListItems.Add , , "PNPDeviceID"
End With
Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
InstancesOf("Win32_PointingDevice")
'fill in respective data
For Each obj In wmiObjSet
With ListView1
.ColumnHeaders.Add , , obj.Description
thiscol = (.ColumnHeaders.Count - 1)
.ListItems(1).SubItems(thiscol) = obj.Description
.ListItems(2).SubItems(thiscol) = obj.Status
Select Case obj.ConfigManagerErrorCode
Case 0: msg = "This device is working properly."
Case 1: msg = "This device is not configured correctly."
Case 2: msg = "Windows cannot load the driver for this device."
Case 3: msg = "The driver might be corrupted, or your system " & _
"may be running low on memory or other resources."
Case 4: msg = "This device is not working properly. One of its " & _
"drivers or your registry might be corrupted."
Case 5: msg = "The driver for this device needs a resource " & _
"that Windows cannot manage."
Case 6: msg = "The boot configuration for this device " & _
"conflicts with other devices."
Case 7: msg = "Cannot filter."
Case 8: msg = "The driver loader for the device is missing."
Case 9: msg = "This device is not working properly because" & _
"the controlling firmware is reporting the " & _
"resources for the device incorrectly."
Case 10: msg = "This device cannot start."
Case 11: msg = "This device failed."
Case 12: msg = "This device cannot find enough free " & _
"resources that it can use."
Case 13: msg = "Windows cannot verify this device's resources."
Case 14: msg = "This device cannot work properly until " & _
"you restart your computer."
Case 15: msg = "This device is not working properly because " & _
"there is probably a re-enumeration problem."
Case 16: msg = "Windows cannot identify all the resources this device uses."
Case 17: msg = "This device is asking for an unknown resource type."
Case 18: msg = "Reinstall the drivers for this device."
Case 19: msg = "Failure using the VXD loader."
Case 20: msg = "Your registry might be corrupted."
Case 21: msg = "System failure: Try changing the driver for this device. " & _
"If that does not work, see your hardware " & _
"documentation. Windows is removing this device."
Case 22: msg = "This device is disabled."
Case 23: msg = "System failure: Try changing the driver for " & _
"this device. If that doesn't work, see your " & _
"hardware documentation."
Case 24: msg = "This device is not present, is not working " & _
"properly, or does not have all its drivers installed."
Case 25: msg = "Windows is still setting up this device."
Case 26: msg = "Windows is still setting up this device."
Case 27: msg = "This device does not have valid log configuration."
Case 28: msg = "The drivers for this device are not installed."
Case 29: msg = "This device is disabled because the firmware of " & _
"the device did not give it the required resources."
Case 30: msg = "This device is using an Interrupt Request (IRQ) " & _
"resource that another device is using."
Case 31: msg = "This device is not working properly because Windows " & _
"cannot load the drivers required for this device."
End Select
楼主你真不幸
请不要发表可能给我们带来伤害的言论,谢谢配合
我发一个代码怎么老出现上面的话
你加我的MSN我传给你[email protected]