Welcome To My Blog

I Blog For Pleasure

Jumat, September 17, 2010

VB.NET check for an application process

1. Add a new function called "checkProcesses" to your VB.NET project. Inside the function, then type "Dim procRunning() As Process" to declare an array to hold all processes.


2. Type "procRunning = Process.GetProcesses" to get all processes currently running.



3.Type "

For Each procs As Process In procRunning

If procs.ProcessName.Equals("EXCEL") Then

MessageBox.Show("Excel is running")

End If

Next".



This code is to create a "For Loop" to loop through all the processes in the "procRunning" array and the "If" statement is to check if the "EXCEL" process is running.


4.Open Microsoft Excel. Run your program to execute the "checkProcesses" function. You will see a message box that says "Excel is running".

Tidak ada komentar: