LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System.Management.ManagementClass in .NET

I have been trying to convert the following to LV but am getting stuck...

System.Management.ManagementClass mc =
new
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration");

ArrayList list = new ArrayList();
foreach ( System.Management.ManagementObject mo in mc.GetInstances() )
{
if ( ((bool)mo["IPEnabled"]) == true )
......>etc.
}

now - the examples use string based stuff, ManagementClass requires a "path"....

Any ideas?

Dav.e
0 Kudos
Message 1 of 3
(4,297 Views)
In the C# example, you automatically end up creating a temp ManagementPath object, since the ManagementPath object has a constructor that takes a string. But if you are using this from LabVIEW, you will need to first manually create the ManagementPath object, provide it the string you need, and then pass the reference of that Management object to the ManagementClass constructor.

I have attached an example of this.

So it wasnt using a LabVIEW path objet, but as the documentation specifies, it expects a ManagementPath object.

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 3
(4,297 Views)

in Dotnet is

 

Imports System.Management
Imports System.Management.ManagementClass
Imports System.Management.ManagementBaseObject
Imports System.Management.ManagementObjectCollection

 

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
ListBox1.Items.Add("Endereço Físico : " & mo.Item("MacAddress").ToString())

End If

Next

End Sub

 

Notes: Listbox1 is better than textbox for create itens; GL .

0 Kudos
Message 3 of 3
(3,538 Views)