Dim connection As New ConnectionOptions
connection.Username = user
connection.Password = pass
Dim scope As New ManagementScope( _
"\\" & host & "\root\CIMV2", connection)
scope.Connect()
比较费时,现在想定义一个scope数组,保存下每一台计算机的connect,以后就可以直接调用,所以在模块里定义了
Public connection As New ConnectionOptions
Public scope() As ManagementScope
然后在程序的LoadHostList之后用
ReDim Preserve scope(lstHost.Items.Count - 1)对数组的范围进行重新定义,再想
For i = 0 To lstHost.Items.Count - 1
connection.Username = lstUser.Items.Item(i)
connection.Password = lstPassWord.Items.Item(i)
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i) & "\root\CIMV2", connection)
scope(i).Connect()
Next
对每一台计算机进行连接时出错,出错位置在
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i) & "\root\CIMV2", connection)
出错提示为
错误 7 重载决策失败,原因是没有可访问的“New”能够不经收缩转换即可被调用:
'Public Sub New(path As System.Management.ManagementPath, options As System.Management.ConnectionOptions)': 与参数“path”匹配的参数从“Object”类型转换为“System.Management.ManagementPath”类型。
'Public Sub New(path As String, options As System.Management.ConnectionOptions)': 与参数“path”匹配的参数从“Object”类型转换为“String”类型。 E:\VS.Project\GetRemote.VB\Monitor\Monitor\Explorer1.vb 239 24 Monitor
请各位朋友给看看,急,在线等,解决后立即结贴。
MSN:pollux_sky@hotmail.com
5 个解决方案
#1
Try:
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i).ToString() & "\root\CIMV2", connection)
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i).ToString() & "\root\CIMV2", connection)
#2
呵呵,搞定,谢谢,悔不该当初VS.NET刚出来的时候没有砸锅卖铁升级硬件以跟上MS的脚步啊,弄得现在VS.NET里的语法都不会了。:)
#3
哈,这么夸张的
#4
微软的东西确实越来越占用资源,Vista真让人担心
#5
VS.NET刚出来时我们那儿还没有D版的光盘卖,当时就请在深圳的朋友给EMS了一套D版回来,等收到就傻了,CII633+128M根本跑不动,当时还只是个穷学生,没钱升级电脑,只好放弃了。
#1
Try:
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i).ToString() & "\root\CIMV2", connection)
scope(i) = New ManagementScope( _
"\\" & lstHost.Items.Item(i).ToString() & "\root\CIMV2", connection)
#2
呵呵,搞定,谢谢,悔不该当初VS.NET刚出来的时候没有砸锅卖铁升级硬件以跟上MS的脚步啊,弄得现在VS.NET里的语法都不会了。:)
#3
哈,这么夸张的
#4
微软的东西确实越来越占用资源,Vista真让人担心
#5
VS.NET刚出来时我们那儿还没有D版的光盘卖,当时就请在深圳的朋友给EMS了一套D版回来,等收到就傻了,CII633+128M根本跑不动,当时还只是个穷学生,没钱升级电脑,只好放弃了。