Friday, 23 November 2007

chapter 10, lesson 4: Detecting Management Events.

.System.Management namespace - tools to monitor + manage the system, devices and apps ~ WMI technology.

Enumerating Management Objects
  • DirectoryObjectSearcher obj - to programatically access resources ~ WMI.
  • mimics SQL.
  • To execute query:
    1. ConnectionOptions (UserName, Password). 2. instance of DirectoryObjectSearcher, 3. Instance of ManagementScope obj - set path 4. Instance of ObjectQuery obj., 5. ManagementObjectCollection = DirectoryObjectSearcher.Get()
  • enumerating logical drives - specify target - e.g. Win32_LogicalDisk.
  • enumerating network adapters - Win32_NetworkConfiguration - new ManagemmentObjectSearcher("SELECT * FRO MWin32_NetworkConfiguration");
  • enumerating windows services - Win32_Service - ManagementObjectCollection AllObjects = DemoSearcher.Get();

No comments: