本文整理匯總了VB.NET中System.Diagnostics.Process.MachineName屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Process.MachineName屬性的具體用法?VB.NET Process.MachineName怎麽用?VB.NET Process.MachineName使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.MachineName屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: GetProcessesByNameClass
' 導入命名空間
Imports System.Diagnostics
Class GetProcessesByNameClass
'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
Main(Environment.GetCommandLineArgs())
End Sub
Public Overloads Shared Sub Main(ByVal args() As String)
Console.WriteLine("Create notepad processes on remote computer")
Console.Write("Enter remote computer name : ")
Dim remoteMachineName As String = Console.ReadLine()
If remoteMachineName Is Nothing Then
' Prepend a new line to prevent it from being on the same line as the prompt.
Console.WriteLine(Environment.NewLine + "You have to enter a remote computer name.")
Return
End If
Try
' 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 ArgumentException
Console.WriteLine("The value '" & remoteMachineName & "' is an invalid remote computer name.")
Catch e As PlatformNotSupportedException
Console.WriteLine(
"Finding notepad processes on remote computers " &
"is not supported on this operating system.")
Catch e As InvalidOperationException
Console.WriteLine("Unable to get process information on the remote computer.")
End Try
End Sub
End Class