This is a continuation of my other tutorial in vb.net that loads and displays the number of startup programs in your computer and then displays it. Now, this tutorial aims to select and remove the retrieved start up programs in our pc.
strong>Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to
File, click
New Project, and choose
Windows Application.
2. Next, add one ListView with two columns, one button that loads the startup programs and another button that removes the startup program, and one label that will be display the number of startup programs. You must design your interface like this:
3. Now, we will do the coding.
First, we will import the Microsoft.Win32 library to access the registry key namespace.
Now, declare some of the variables that we will going to use for loading the number of startup programs and display it on the label.
Dim g As RegistryKey
Dim appname As String
Dim newlistv As New ListView
Dim a As String, m, u, Numberofstartupprograms As Int32
Copy this code below to load the number of startup programs. This was the last tutorial that I have created with loading the startup.
Private Sub ButtonLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoad.Click
'clear the listview and the newlistview
Numberofstartupprograms = 0
ListView1.Items.Clear()
newlistv.Items.Clear()
' accessing the local machine of the registy
g = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
' get all the startup programs
For Each item In g.GetValueNames
Numberofstartupprograms += 1
'get the path of the name
appname = CStr(g.GetValue(item))
Application.DoEvents()
' added the startup programs to the listview
ListView1.Items.Add(appname).SubItems.Add(item)
newlistv.Items.Add(item)
'retrieved the total number of programs on the label
Label1.Text = "Total Start-up: " & Numberofstartupprograms
Next
End Sub
Lastly, for our main code in removing the selected start up programs, we will declare first this variables.
Dim value As String, number As Int32
Now, to remove the selected startup programs, have this code below:
Private Sub ButtonRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemove.Click
If Not ListView1.SelectedItems.Count = 0 Then
number = ListView1.SelectedItems(0).Index
g.DeleteValue(newlistv.Items(number).Text)
MsgBox(ListView1
.SelectedItems(0).Text & " was succesfully deleted", MsgBoxStyle
.Information) ListView1.Items.RemoveAt(number)
End If
End Sub
Output:
Download the code and try it.
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:
[email protected]
Add and Follow me on Facebook:
https://www.facebook.com/donzzsky
Visit and like my page on Facebook at:
https://www.facebook.com/BermzISware