Device.GetRemoteProcess 方法
更新:2007 年 11 月
建立並傳回 RemoteProcess 的執行個體,用以啟動或結束裝置上的處理序 (Process)。
命名空間: 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());
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。