From: alexia.bee on
Hi all,

I want to be notified using WMI when IP address is being changed.
The following code is good for disable/enable device:
WqlEventQuery query = new WqlEventQuery("SELECT * FROM
__InstanceModificationEvent WITHIN 2 WHERE TargetInstance ISA
\"Win32_NetworkAdapter\"");
//WqlEventQuery query = new WqlEventQuery("SELECT * FROM
__InstanceModificationEvent WITHIN 2 WHERE TargetInstance ISA
\"Win32_NetworkAdapterConfiguration\"");

// Initialize an event watcher and subscribe to events that match this
query
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.Query = query;
while (true)
{
ManagementBaseObject e = watcher.WaitForNextEvent();
Console.WriteLine("Description:\t\t {0} ",
((ManagementBaseObject)e["TargetInstance"])["Description"]);
Console.WriteLine("ConfigManagerErrorCode:\t {0} ",
((ManagementBaseObject)e["TargetInstance"])
["ConfigManagerErrorCode"]);
Console.WriteLine("NetConnectionStatus:\t {0} ",
((ManagementBaseObject)e["TargetInstance"])["NetConnectionStatus"]);
}
//Cancel the subscription
watcher.Stop();
for IP addresss I should use class
"Win32_NetworkAdapterConfiguration". any idea how to do it?
One more thing. When state is changed to disabled\enabled, I only get
Disconnected/Connected
Device is working properly/Device is disabled
Any idea why I don't get also: Connecting/Disconnecting/Authenticating
status

thanks.