Device.GetRunningProcesses Method
Returns list of processes running on the device.
Namespace: Microsoft.SmartDevice.Connectivity
Assembly: Microsoft.SmartDevice.Connectivity (in Microsoft.SmartDevice.Connectivity.dll)
Syntax
'Declaration
Public Function GetRunningProcesses As Collection(Of RemoteProcess)
'Usage
Dim instance As Device
Dim returnValue As Collection(Of RemoteProcess)
returnValue = instance.GetRunningProcesses()
public Collection<RemoteProcess> GetRunningProcesses()
public:
Collection<RemoteProcess^>^ GetRunningProcesses()
public function GetRunningProcesses() : Collection<RemoteProcess>
Return Value
Type: System.Collections.ObjectModel.Collection<RemoteProcess>
Returns a collection.
Exceptions
Exception | Condition |
---|---|
DeviceNotConnectedException | The device is not connected. |
SmartDeviceException | A COM exception is thrown by underlying COM components. |
Remarks
The device must be connected.
Examples
' Start the Calculator
Dim rp As RemoteProcess = device.GetRemoteProcess()
rp.Start("\windows\calc.exe", "")
' List all running processes
Console.WriteLine("Type the number of the process you want to end" & _
vbCr & vbLf)
Dim processes As Collection(Of RemoteProcess) = device.GetRunningProcesses()
Dim i As Integer
For i = 0 To processes.Count - 1
Console.WriteLine(i & ") " & processes(i).FileName & _
" [" & processes(i).ToString() & "]")
Next i
' Get user input and end the process
Dim index As Integer = Convert.ToInt32(Console.ReadLine())
Console.WriteLine("Attempting to stop " & processes(index).FileName)
processes(index).Kill()
If processes(index).HasExited() Then
Console.WriteLine("Process is no longer running")
End If
// Start the Calculator.
RemoteProcess rp = device.GetRemoteProcess();
rp.Start("\\windows\\calc.exe", "");
// List all running processes.
Console.WriteLine("Type the number of the process you want to end\r\n");
Collection<RemoteProcess> processes = device.GetRunningProcesses();
for (int i = 0; i < processes.Count; i+)
{
Console.WriteLine(i + ") " + processes[i].FileName +
" [" + processes[i].ToString() + "]");
}
// Get user input and end the process.
int index = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Attempting to stop " + processes[index].FileName);
processes[index].Kill();
if (processes[index].HasExited())
{
Console.WriteLine("Process exited with code: " +
processes[index].GetExitCode());
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.