Question: You need to write a code segment that performs the following tasks:
Retrieve the name of each paused service.
Passe the name to the Add method of Collection1.
Which code segment should you use?
A
B
C
D
Dim searcher As ManagementObjectSearcher = _
New ManagementObjectSearcher( _
"Select * from Win32_Service where State = 'Paused'") For Each svc As ManagementObject In
searcher.Get()
Collection1.Add(svc("DisplayName"))
Next
New ManagementObjectSearcher( _
"Select * from Win32_Service where State = 'Paused'") For Each svc As ManagementObject In
searcher.Get()
Collection1.Add(svc("DisplayName"))
Next
B
Dim searcher As ManagementObjectSearcher = _
New ManagementObjectSearcher( _
"Select * from Win32_Service")
For Each svc As ManagementObject In searcher.Get()
If svc("State").ToString() = "'Paused'" Then
Collection1.Add(svc("DisplayName"))
End If
Next
New ManagementObjectSearcher( _
"Select * from Win32_Service")
For Each svc As ManagementObject In searcher.Get()
If svc("State").ToString() = "'Paused'" Then
Collection1.Add(svc("DisplayName"))
End If
Next
C
Dim searcher As New ManagementObjectSearcher()
searcher.Scope = New ManagementScope("Win32_Service") For Each svc As ManagementObject In searcher.Get()
If svc("State").ToString() = "Paused" Then
Collection1.Add(svc("DisplayName"))
End If
Next
searcher.Scope = New ManagementScope("Win32_Service") For Each svc As ManagementObject In searcher.Get()
If svc("State").ToString() = "Paused" Then
Collection1.Add(svc("DisplayName"))
End If
Next
D
Dim searcher As ManagementObjectSearcher = _
New ManagementObjectSearcher ( _
"Select * from Win32_Service", "State = 'Paused'")
For Each svc As ManagementObject In searcher.Get()
Collection1.Add(svc("DisplayName"))
Next
New ManagementObjectSearcher ( _
"Select * from Win32_Service", "State = 'Paused'")
For Each svc As ManagementObject In searcher.Get()
Collection1.Add(svc("DisplayName"))
Next
Note: Not available