- Код: Выделить всё
Dim diskClass As New System.Management.ManagementObjectSearcher("Select * FROM Win32_DiskDrive")
Dim disk As System.Management.ManagementObject
Dim s As String = ""
For Each disk In diskClass.Get()
AAA(i) = disk("SerialNumber")
i = i + 1
Next disk
если на компе стоит Win7 то все ок
если на тот же комп поставить XP sp2-sp3 то данный код вызывает ошибку.
System.Management.ManagementException не обработано
Message="Не найден "
Source="System.Management"
StackTrace:
в System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) в System.Management.PropertyData.RefreshPropertyInfo() в System.Management.PropertyDataCollection.get_Item(String propertyName) в System.Management.ManagementBaseObject.GetPropertyValue(String propertyName) в System.Management.ManagementBaseObject.get_Item(String propertyName) в NLE_TEL.Menu_vb.loadsystem() в C:\Documents and Settings\likhoded\Рабочий стол\NLE TEL\NLE TEL\Menu_vb.vb:строка 17 в NLE_TEL.Menu_vb.Menu_vb_Load(Object sender, EventArgs e) в C:\Documents and Settings\likhoded\Рабочий стол\NLE TEL\NLE TEL\Menu_vb.vb:строка 307 в System.EventHandler.Invoke(Object sender, EventArgs e) в System.Windows.Forms.Form.OnLoad(EventArgs e) в System.Windows.Forms.Form.OnCreateControl() в System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) в System.Windows.Forms.Control.CreateControl() в System.Windows.Forms.Control.WmShowWindow(Message& m) в System.Windows.Forms.Control.WndProc(Message& m) в System.Windows.Forms.ScrollableControl.WndProc(Message& m) в System.Windows.Forms.ContainerControl.WndProc(Message& m) в System.Windows.Forms.Form.WmShowWindow(Message& m) в System.Windows.Forms.Form.WndProc(Message& m) в System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) в System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) в System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) в System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) в System.Windows.Forms.Control.SetVisibleCore(Boolean value) в System.Windows.Forms.Form.SetVisibleCore(Boolean value) в System.Windows.Forms.Control.set_Visible(Boolean value) в System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) в System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) в System.Windows.Forms.Application.Run(ApplicationContext context) в Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() в Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() в Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) в NLE_TEL.My.MyApplication.Main(String[] Args) в 17d14f5c-a337-4978-8281-53493378c1071.vb:строка 81 в System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() в System.Threading.ThreadHelper.ThreadStart_Context(Object state) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ThreadHelper.ThreadStart()
InnerException:
в чем косяк?