Trying to retrieve the IP address. But this is giving exception to
Object references are not set for an example of an object.
ManagementScope scope = new ManagementScope ("\\\" \ \ root \\ cimv2 "); ObjectQuery query1 = new object city (" Select * Win32_NetworkAdapterConfiguration ") ; Management object explorer explorer = new management object search (area, query1); ManagementObjectCollection query = finder 1. get (); foreign currency (Management object M in query) {listBox2.Items.Add (m ["DefaultIPGateway"]. ToString );}
Try:
Management scope scope = New ManagementScope ("\\\\ \" heavy \\ cimv2.); ObjectQuery query1 = New Object City ("Select * Win32_NetworkAdapterConfiguration"); Management object explorer explorer = new management object search (field, query1); ManagementObjectCollection query = finder 1. get (); in foreach Management object m) {If {{"Default IP gateway"] = null) {listBox2.Items.Add (m ["DefaultIPGateway"]. ToString ()); }}
No comments:
Post a Comment