Get the list of running applications
Use this board to post your code snippets - tips and tricks
1 post
Page 1 of 1
In this tutorial I’ll show you how to get a list of running applications:
For this tutorial you need a button and a textbox:
First add these 2 declerations to your code page.
Then add the following function:
For this tutorial you need a button and a textbox:
First add these 2 declerations to your code page.
Code: Select all
The above 2 lines of code should be on the very top of the page code:Imports System.Text
Imports System.Management
Then add the following function:
Code: Select all
Then add the following code to the button click event:Public Shared Function getApplications() As String
Dim a As New StringBuilder()
Dim b As New Process()
For Each b In Process.GetProcesses(".")
Try
If b.MainWindowTitle.Length > 0 Then
a.Append("Window Title: " + b.MainWindowTitle.ToString() + Environment.NewLine)
a.Append("Process Name: " + b.ProcessName.ToString() + Environment.NewLine)
a.Append(Environment.NewLine)
End If
Catch
End Try
Next
Return a.ToString()
End Function
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = getApplications()
End Sub
Below is a the whole code page:
Imports System.Text
Imports System.Management
Public Class Form1
Public Shared Function getApplications() As String
Dim a As New StringBuilder()
Dim b As New Process()
For Each b In Process.GetProcesses(".")
Try
If b.MainWindowTitle.Length > 0 Then
a.Append("Window Title: " + b.MainWindowTitle.ToString() + Environment.NewLine)
a.Append("Process Name: " + b.ProcessName.ToString() + Environment.NewLine)
a.Append(Environment.NewLine)
End If
Catch
End Try
Next
Return a.ToString()
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = getApplications()
End Sub
End Class
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023