Get current Process : Process « Development « VB.Net Tutorial






Imports System.Diagnostics
Module Module1

    Sub Main()
        Dim objProcess As New Process()

        objProcess = Process.GetCurrentProcess()

        With objProcess
            Console.WriteLine("Base Priority {0}", .BasePriority)
            Console.WriteLine("Handle count {0}", .HandleCount)
            Console.WriteLine("Process ID (PID) {0}", .Id)
            Console.WriteLine("Machine Name {0}", .MachineName)
            Console.WriteLine("Main Module {0}", .MainModule)
            Console.WriteLine("Main Window Title {0}", .MainWindowTitle)
            Console.WriteLine("Max Working Set {0}", .MaxWorkingSet)
            Console.WriteLine("Min Working Set {0}", .MinWorkingSet)
            Console.WriteLine("Modules {0}", .Modules)
            Console.WriteLine("Nonpage System Memory Size {0}",.NonpagedSystemMemorySize)
            Console.WriteLine("Paged Memory Size {0}", .PagedMemorySize)
            Console.WriteLine("Paged System Memory Size {0}",.PagedSystemMemorySize)
            Console.WriteLine("Peak Paged Memory Size {0}",.PeakPagedMemorySize)
            Console.WriteLine("Peak Virtual Memory Size {0}",.PeakVirtualMemorySize)
            Console.WriteLine("Peak Working Set {0}", .PeakWorkingSet)
            Console.WriteLine("Priority Boost Enabled {0}", .PriorityBoostEnabled)
            Console.WriteLine("Priority Class {0}", .PriorityClass)
            Console.WriteLine("Private Memory Size {0}",.PrivateMemorySize)
            Console.WriteLine("Priviledged Processsor Time {0}",.PrivilegedProcessorTime)
            Console.WriteLine("Name {0}", .ProcessName)
            Console.WriteLine("Processor Affinity {0}", .ProcessorAffinity)
            Console.WriteLine("Start Time {0}", .StartTime)
            Console.WriteLine("Total Processor Time {0}", .TotalProcessorTime)
            Console.WriteLine("User Processor Time {0}", .UserProcessorTime)
            Console.WriteLine("Virtual Memory Size {0}", .VirtualMemorySize)
            Console.WriteLine("Working Set {0}", .WorkingSet)
        End With
    End Sub

End Module
Base Priority 8
Handle count 87
Process ID (PID) 2988
Machine Name .
Main Module System.Diagnostics.ProcessModule (main.exe)
Main Window Title
Max Working Set 1413120
Min Working Set 204800
Modules System.Diagnostics.ProcessModuleCollection
Nonpage System Memory Size 4508
Paged Memory Size 9330688
Paged System Memory Size 105068
Peak Paged Memory Size 9330688
Peak Virtual Memory Size 92123136
Peak Working Set 5308416
Priority Boost Enabled True
Priority Class Normal
Private Memory Size 9330688
Priviledged Processsor Time 00:00:00.0312500
Name main
Processor Affinity 1
Start Time 11/05/2007 9:33:27 PM
Total Processor Time 00:00:00.0781250
User Processor Time 00:00:00.0468750
Virtual Memory Size 92057600
Working Set 5308416








7.24.Process
7.24.1.Start process by setting file name
7.24.2.Get current Process
7.24.3.Display properties of current Process
7.24.4.Start main module in current process
7.24.5.Kill current process
7.24.6.Get thread count in current process
7.24.7.Get Process by ID
7.24.8.Print properties of Process
7.24.9.Open Default editor for text file
7.24.10.Start a processStart a process
7.24.11.List all process in a ListViewList all process in a ListView