Udostępnij za pośrednictwem


RemoteProcess.GetExitCode Method

Gets exit code of the process that has the same FileName.

Namespace:  Microsoft.SmartDevice.Connectivity
Assembly:  Microsoft.SmartDevice.Connectivity (in Microsoft.SmartDevice.Connectivity.dll)

Syntax

'Declaration
Public Function GetExitCode As Integer
'Usage
Dim instance As RemoteProcess 
Dim returnValue As Integer 

returnValue = instance.GetExitCode()
public int GetExitCode()
public:
int GetExitCode()
public function GetExitCode() : int

Return Value

Type: System.Int32
Returns Int32 process exit code value.

Exceptions

Exception Condition
InvalidOperationException

With a message string "Remote Process has not started", is thrown when the remote process has not started or "Remote Process has not exited" when remote process has not exited yet.

SmartDeviceException

An error occurred in the underlying COM components.

DeviceNotConnectedException

The device is not connected.

Remarks

The exit code, return code, or error level is a numeric value returned by a terminating process to its parent process. Every process implements its own set of return codes but, generally, a return code of zero means the process executed and terminated successfully. A non-zero return code generally means the process executed abnormally.

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

See Also

Reference

RemoteProcess Class

RemoteProcess Members

Microsoft.SmartDevice.Connectivity Namespace