首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么包裹錯誤處理

2012-06-08 
如何包裹錯誤處理在下面這個函數中屬性oHwInf.MUILanguages(0)在非W7系統下好像不存在,造成賦值出錯我如何

如何包裹錯誤處理
在下面這個函數中屬性oHwInf.MUILanguages(0)在非W7系統下好像不存在,造成賦值出錯
我如何把這個錯誤包裹起來,繼續運行,讓它賦值=空就可以了呢

Public Function ReadSoftinfo()

'On Error GoTo hErr
Dim osoft As SOFT

'(2)ノWMI掃描系統信息
Set oResults = oCimv2.ExecQuery("select * from Win32_OperatingSystem", , 48)
For Each oHwInf In oResults
'Caption,Manufacturer,Version,WindowsDirectory,InstallDate,SerialNumber,MUILanguages,RegisteredUser
 Set osoft = New SOFT
 osoft.SoftTpye = "OS"
 osoft.SoftCaption = clean((oHwInf.Caption))
 osoft.SoftManufacturer = clean(oHwInf.Manufacturer)
 osoft.SoftVersion = clean(oHwInf.Version)
 osoft.SoftWindowsDirectory = clean(oHwInf.WindowsDirectory)
 osoft.SoftInstallDate = Left(clean(oHwInf.InstallDate), 14)

 osoft.SoftMUILanguages = (clean(oHwInf.MUILanguages(0)))
 osoft.SoftSerialNumber = clean(oHwInf.SerialNumber)

 osofts.Add osoft
Next


'Set oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'softinfs2

Exit Function

[解决办法]
Public Function ReadSoftinfo()

On Error GoTo hErr
Dim osoft As SOFT

'(2)ノWMI掃描系統信息
Set oResults = oCimv2.ExecQuery("select * from Win32_OperatingSystem", , 48)
For Each oHwInf In oResults
'Caption,Manufacturer,Version,WindowsDirectory,InstallDate,SerialNumber,MUILanguages,RegisteredUser
 Set osoft = New SOFT
 osoft.SoftTpye = "OS"
 osoft.SoftCaption = clean((oHwInf.Caption))
 osoft.SoftManufacturer = clean(oHwInf.Manufacturer)
 osoft.SoftVersion = clean(oHwInf.Version)
 osoft.SoftWindowsDirectory = clean(oHwInf.WindowsDirectory)
 osoft.SoftInstallDate = Left(clean(oHwInf.InstallDate), 14)

 osoft.SoftMUILanguages = (clean(oHwInf.MUILanguages(0)))
 osoft.SoftSerialNumber = clean(oHwInf.SerialNumber)

 osofts.Add osoft
Next


'Set oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'softinfs2
hErr:
if err.numer=??? then '???你自己跟踪一下该错误号
resume next '这样处理后,如果是该错误,就会返回到出错的下一句执行
end if
Exit Function 


[解决办法]
你的这个东西 是wmi wmi有些是需要有系统和库支持的 有些东西 是木有的 xp

热点排行