Device.GetRemoteProcess 方法
更新:2007 年 11 月
创建并返回一个 RemoteProcess 实例,该实例用于启动或终止设备上的进程。
命名空间: Microsoft.SmartDevice.Connectivity
程序集: Microsoft.SmartDevice.Connectivity(在 Microsoft.SmartDevice.Connectivity.dll 中)
语法
声明
Public Function GetRemoteProcess As RemoteProcess
用法
Dim instance As Device
Dim returnValue As RemoteProcess
returnValue = instance.GetRemoteProcess()
public RemoteProcess GetRemoteProcess()
public:
RemoteProcess^ GetRemoteProcess()
public function GetRemoteProcess() : RemoteProcess
返回值
类型:Microsoft.SmartDevice.Connectivity.RemoteProcess
返回一个 RemoteProcess 类型的对象。
异常
异常 | 条件 |
---|---|
DeviceNotConnectedException | 未连接设备。 |
SmartDeviceException | 基础 COM 组件引发了一个 COM 异常。 |
备注
必须连接该设备。
示例
' 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());
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。