Process.MachineName プロパティ
アセンブリ: System (system.dll 内)



リモート コンピュータで実行されているプロセスの統計データとプロセス情報は表示できますが、リモート コンピュータで Start、CloseMainWindow、または Kill を呼び出すことはできません。
![]() |
---|
関連付けられたプロセスがローカル マシンで実行されている場合、このプロパティはマシン名に対してピリオド (".") を返します。正しいマシン名を取得するには、Environment.MachineName プロパティを使用してください。 |

次の例を使用するには、最初に 1 つ以上のメモ帳のインスタンスをリモート コンピュータで開始しておく必要があります。この例は、メモ帳が動作しているリモート コンピュータの名前を要求し、次に各インスタンスに対して ProcessName、Id、およびMachineName の各プロパティを表示します。
Imports System Imports System.Diagnostics Imports Microsoft.VisualBasic Class GetProcessesByNameClass 'Entry point which delegates to C-style main Private Function Public Overloads Shared Sub Main() Main(System.Environment.GetCommandLineArgs()) End Sub Public Overloads Shared Sub Main(ByVal args() As String) Try Console.Writeline("Create notepad processes on remote computer") Console.Write("Enter remote computer name : ") Dim remoteMachineName As String = Console.ReadLine() ' Get all notepad processess into Process array. Dim myProcesses As Process() = Process.GetProcessesByName _ ("notepad", remoteMachineName) If myProcesses.Length = 0 Then Console.WriteLine("Could not find notepad processes on remote computer.") End If Dim myProcess As Process For Each myProcess In myProcesses Console.WriteLine("Process Name : " & myProcess.ProcessName & _ " Process ID : " & myProcess.Id & _ " MachineName : " & myProcess.MachineName) Next myProcess Catch e As SystemException Console.Write("Caught Exception .... : " & e.Message) Catch e As Exception Console.Write("Caught Exception .... : " & e.Message) End Try End Sub 'Main End Class 'GetProcessesByNameClass
using System; using System.Diagnostics; class GetProcessesByNameClass { public static void Main(string[] args) { try { Console.Write("Create notepad processes on remote computer \n"); Console.Write("Enter remote computer name : "); string remoteMachineName = Console.ReadLine(); // Get all notepad processess into Process array. Process[] myProcesses = Process.GetProcessesByName("notepad",remoteMachineName); if(myProcesses.Length == 0) Console.WriteLine("Could not find notepad processes on remote computer."); foreach(Process myProcess in myProcesses) { Console.Write("Process Name : " + myProcess.ProcessName + " Process ID : " + myProcess.Id + " MachineName : " + myProcess.MachineName + "\n"); } } catch(SystemException e) { Console.Write("Caught Exception .... : " + e.Message); } catch(Exception e) { Console.Write("Caught Exception .... : " + e.Message); } } }
#using <System.dll> using namespace System; using namespace System::Diagnostics; int main() { try { Console::Write( "Create notepad processes on remote computer \n" ); Console::Write( "Enter remote computer name : " ); String^ remoteMachineName = Console::ReadLine(); // Get all notepad processess into Process array. array<Process^>^myProcesses = Process::GetProcessesByName( "notepad", remoteMachineName ); if ( myProcesses->Length == 0 ) Console::WriteLine( "Could not find notepad processes on remote computer." ); Collections::IEnumerator^ myEnum = myProcesses->GetEnumerator(); while ( myEnum->MoveNext() ) { Process^ myProcess = safe_cast<Process^>(myEnum->Current); Console::Write( "Process Name : {0} Process ID : {1} MachineName : {2}\n", myProcess->ProcessName, myProcess->Id, myProcess->MachineName ); } } catch ( SystemException^ e ) { Console::Write( "Caught Exception .... : {0}", e->Message ); } catch ( Exception^ e ) { Console::Write( "Caught Exception .... : {0}", e->Message ); } }


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からProcess.MachineName プロパティを検索する場合は、下記のリンクをクリックしてください。

- Process.MachineName プロパティのページへのリンク