本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System.Diagnostics,代码行数:45,代码来源:Process.MachineName
注:本文中的System.Diagnostics.Process.MachineName属性示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论