1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
int main()
{
// Get the current process.
Process^ currentProcess = Process::GetCurrentProcess();
// Get all instances of Notepad running on the local
// computer.
array<Process^>^localByName = Process::GetProcessesByName( "notepad" );
// Get all instances of Notepad running on the specific
// computer.
// 1. Using the computer alias (do not precede with "\\").
array<Process^>^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" );
// 2. Using an IP address to specify the machineName parameter.
array<Process^>^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" );
// Get all processes running on the local computer.
array<Process^>^localAll = Process::GetProcesses();
// Get all processes running on the remote computer.
array<Process^>^remoteAll = Process::GetProcesses( "myComputer" );
// Get a process on the local computer, using the process id.
Process^ localById = Process::GetProcessById( 1234 );
// Get a process on a remote computer, using the process id.
Process^ remoteById = Process::GetProcessById( 2345, "myComputer" );
} |
Partager