Share via


RemoteProcess 클래스

업데이트: 2007년 11월

시작 및 중지할 수 있는 장치의 프로세스를 나타냅니다.

네임스페이스:  Microsoft.SmartDevice.Connectivity
어셈블리:  Microsoft.SmartDevice.Connectivity(Microsoft.SmartDevice.Connectivity.dll)

구문

Public Class RemoteProcess

Dim instance As RemoteProcess
public class RemoteProcess
public ref class RemoteProcess
public class RemoteProcess

설명

이 개체의 인스턴스를 가져오려면 Device.GetRemoteProcess 메서드를 사용합니다.

예제

Imports System
Imports System.Collections.ObjectModel
Imports Microsoft.SmartDevice.Connectivity



Class [source]

    Shared Sub Main(ByVal args() As String) 

        ' Get the datastore object.
        Dim dsmgr As New DatastoreManager(1033)

        ' Get the platform object.
        Dim platform As Platform = GetPlatformByName("Windows Mobile 5.0 Pocket PC SDK", dsmgr)

        Try
            ' Get the default device in the platform, usually an emulator.
            Dim device As Device = platform.GetDevice(platform.GetDefaultDeviceId())

            device.Connect()

            If device.IsConnected() Then
                ' 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
                ' pause
                Console.Read()
            End If

        Catch e As System.Exception
            Console.WriteLine(e.Message)
            Console.Read()
        End Try

    End Sub 'Main



    ' Returns a platform if the supplied name can be found in the datastore.  
    ' Returns null pointer if platform cannot be found
    Private Shared Function GetPlatformByName(ByVal p As String, _
                                              ByVal dsmgr As DatastoreManager) As Platform
        ' Get all platforms in the datastore.
        Dim platforms As Collection(Of Platform) = dsmgr.GetPlatforms()

        ' Find the platform whose name matches the parameter.
        Dim platform As Platform
        For Each platform In platforms
            If platform.Name = p Then
                Return platform
            End If
        Next platform
        Return Nothing

    End Function 'GetPlatformByName
End Class '[source]
using System;
using System.Collections.ObjectModel;
using Microsoft.SmartDevice.Connectivity;

class source
{
    static void Main(string[] args)
    {

        // Get the datastore object.
        DatastoreManager dsmgr = new DatastoreManager(1033);

        // Get the platform object.
        Platform platform = GetPlatformByName("Windows Mobile 5.0 Pocket PC SDK", dsmgr);

        try
        {
            // Get the default device in the platform, usually an emulator.
            Device device = platform.GetDevice(platform.GetDefaultDeviceId());

            device.Connect();

            if (device.IsConnected())
            {
                // 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());
                }
                // pause
                Console.Read();
            }
        }

        catch (System.Exception e)
        {
            Console.WriteLine(e.Message);
            Console.Read();
        }
    }


    // Returns a platform if the supplied name can be found in the datastore.
    // Returns null pointer if platform cannot be found.
    private static Platform GetPlatformByName(string p, DatastoreManager dsmgr)
    {
        // Get all platforms in the datastore.
        Collection<Platform> platforms = dsmgr.GetPlatforms();

        // Find the platform whose name matches the parameter.
        foreach (Platform platform in platforms)
        {
            if (platform.Name == p) return platform;
        }
        return null;        
    }
}

상속 계층 구조

System.Object
  Microsoft.SmartDevice.Connectivity.RemoteProcess

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

RemoteProcess 멤버

Microsoft.SmartDevice.Connectivity 네임스페이스