Domain.com has a server named Certkiller -SR05 that has numerous processors installed.
You have been given the task of developing an application that displays certain clock speed statistics
on all processors installed on Certkiller -SR05.
You need to ensure that this requirement is fully satisfied.
What should you do?
A.
Use the following code:
ManagementObjectSearcher processorSearcher = new ManagementObjectSearcher();
foreach (ManagementObject obj in processorSearcher.Get(“SELECT * FROM Win32_Processor”)){
Console.WriteLine (“{0}”, obj [“Name”]);
Console.WriteLine (“{0} / {1}”,
obj [“CurrentClockSpeed”], Obj [“MaxClockSpeed”]);
}
B.
Use the following code:
ManagementObjectSearcher processorSearcher = new ManagementObjectSearcher( “SELECT * FROM Win32_Processor”);
foreach (ManagementObject obj in processorSearcher.Get()){
Console.WriteLine (“{0}”, obj[“Name”]);
Console.WriteLine (“{0} / {1}”,
obj[“CurrentClockSpeed”], obj[“MaxClockSpeed”]);
}
C.
Use the following code:
ManagementObjectQuery processorQuery = new ManagementObjectQuery();
foreach (ManagementObject obj in processorQuery.Get (“SELECT * FROM Win32_Processor”)){
Console.WriteLine (“{0}”, obj[“Name”]);
Console.WriteLine (“{0} / {1}”,
obj[“CurrentClockSpeed”], obj[“MaxClockSpeed”]);
}
D.
Use the following code:
ManagementObjectQuery processorQuery = new ManagementObjectQuery( “SELECT * FROM Win32_Processor”);
foreach (ManagementObject obj in processorQuery.Get()){
Console.WriteLine (“{0}”, obj [“Name”]);
Console.WriteLine (“{0} / {1}”,
obj[“CurrentClockSpeed”], obj[“MaxClockSpeed”]);
}
Explanation:
This code retrieve all Win32_Processor objects on the local machine, iterates through each Win32_Processor object,
and displays the Name, CurrentClockSpeed and MaxClockSpeed properties for each Win32_Processor object.
First, the ManagementObjectSearcher object is instantiated with the WQL query string on which to search.
WQL is a subset of SQL, and it is specifically designed for WMI. The WQL string specified in this code returns any 32-bit processors available on the local machine.
The Get method returns a ManagementObjectCollection object. On each iteration, a ManagementObject object is assigned to the variable obj. The Console.WriteLine method display the Name, ClockSpeed, and MaxClockSpeed properties on the command-line using a string indexer.
Incorrect Answers:
A: You should not use the code that specifies the WQL query string as an argument of the Get method
of the ManagementObjectSearcher object BECAUSE the Get method does not accept a string data type.
C D: You should not use the code that specifies the ManagementObjectQuery class BECAUSE there is no such class in the .NET 2.0 class library.
I have the same idea. B