本文整理汇总了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