当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Process.GetCurrentProcess方法代码示例

本文整理汇总了VB.NET中System.Diagnostics.Process.GetCurrentProcess方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Process.GetCurrentProcess方法的具体用法?VB.NET Process.GetCurrentProcess怎么用?VB.NET Process.GetCurrentProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.Process的用法示例。


在下文中一共展示了Process.GetCurrentProcess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: BindToRunningProcesses

' 导入命名空间
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Sub BindToRunningProcesses()
            ' Get the current process. You can use currentProcess from this point
            ' to access various properties and call methods to control the process.
            Dim currentProcess As Process = Process.GetCurrentProcess()

            ' Get all processes running on the local computer.
            Dim localAll As Process() = Process.GetProcesses()

            ' Get all instances of Notepad running on the local computer.
            ' This will return an empty array if notepad isn't running.
            Dim localByName As Process() = Process.GetProcessesByName("notepad")

            ' Get a process on the local computer, using the process id.
            ' This will throw an exception if there is no such process.
            Dim localById As Process = Process.GetProcessById(1234)


            ' Get processes running on a remote computer. Note that this
            ' and all the following calls will timeout and throw an exception
            ' if "myComputer" and 169.0.0.0 do not exist on your local network.

            ' Get all processes on a remote computer.
            Dim remoteAll As Process() = Process.GetProcesses("myComputer")

            ' Get all instances of Notepad running on the specific computer, using machine name.
            Dim remoteByName As Process() = Process.GetProcessesByName("notepad", "myComputer")

            ' Get all instances of Notepad running on the specific computer, using IP address.
            Dim ipByName As Process() = Process.GetProcessesByName("notepad", "169.0.0.0")

            ' Get a process on a remote computer, using the process id and machine name.
            Dim remoteById As Process = Process.GetProcessById(2345, "myComputer")
        End Sub

        Shared Sub Main()
            Dim myProcess As New MyProcess()
            myProcess.BindToRunningProcesses()
        End Sub

    End Class

End Namespace 'MyProcessSample
开发者ID:VB.NET开发者,项目名称:System.Diagnostics,代码行数:48,代码来源:Process.GetCurrentProcess

示例2: Module1

' 导入命名空间
Imports System.Threading

Module Module1


    Sub Main()
        Dim MatchingNames As System.Diagnostics.Process()

        Dim TargetName As String

        TargetName = System.Diagnostics.Process.GetCurrentProcess.ProcessName

        MatchingNames = System.Diagnostics.Process.GetProcessesByName(TargetName)

        If (MatchingNames.Length = 1) Then
            Console.WriteLine("Started...")
        Else
            Console.WriteLine("Process already running")
        End If
    End Sub

End Module
开发者ID:VB程序员,项目名称:System.Diagnostics,代码行数:23,代码来源:Process.GetCurrentProcess


注:本文中的System.Diagnostics.Process.GetCurrentProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。