VB.Net by API/System.Diagnostics/Process — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:50, 26 мая 2010
Содержание
Process.GetCurrentProcess
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
Process.GetProcessesByName
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
Process.Kill
Imports System.Diagnostics
Module Module1
Sub Main()
" Process.GetCurrentProcess.Kill()
End Sub
End Module
Process.NonpagedSystemMemorySize
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
Process.Start
Imports System
Imports System.Drawing
Imports System.Data
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Xml
Public Class MainClass
Shared Sub Main()
System.Diagnostics.Process.Start("mailto:" & "youremail@yourserver.ru")
End Sub
End Class
Process.StartInfo
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Diagnostics
Imports System.Drawing.Printing
Public Class MainClass
Shared Sub Main()
Dim new_process As New Process
new_process.StartInfo.FileName = Application.ExecutablePath
new_process.StartInfo.Verb = "Open"
new_process.Start()
End Sub
End Class
Process.VirtualMemorySize64
Imports System.Diagnostics
Public Class Tester
Public Shared Sub Main
Dim pid As Integer = 12345
Dim p As Process = Process.GetProcessById(pid)
If p Is Nothing Then Return
Try
Console.WriteLine(p.Id.ToString())
Console.WriteLine(p.ProcessName)
Console.WriteLine(p.StartTime.ToLongTimeString())
Console.WriteLine(p.PriorityClass.ToString())
Console.WriteLine(p.VirtualMemorySize64.ToString())
Console.WriteLine(p.WorkingSet64.ToString())
If p.MainModule IsNot Nothing Then
Console.WriteLine(p.MainModule.FileName)
Console.WriteLine(p.MainModule.FileVersionInfo.FileDescription)
Console.WriteLine(p.MainModule.FileVersionInfo.FileVersion)
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
p.Close()
End Try
End Sub
End Class