Hướng dẫn viết ứng dụng thay đổi (Icon ổ đĩa máy tính) bằng VB.NET
Hôm nay, mình xin hướng dẫn các bạn thay đổi Icon ổ đĩa trong computer bằng một icon mới. Cái này chủ yếu là mình thay đổi registry trong hệ thống, cũng giống như bài hôm trước mình hướng dẫn các bạn khóa taskmanager, cài đặt ứng dụng chạy khi khởi động máy ...
Hôm nay, mình xin hướng dẫn các bạn thay đổi Icon ổ đĩa trong computer bằng một icon mới. Cái này chủ yếu là mình thay đổi registry trong hệ thống, cũng giống như bài hôm trước mình hướng dẫn các bạn khóa taskmanager, cài đặt ứng dụng chạy khi khởi động máy tính...
Các bạn có thể xem qua demo chương trình của mình ở dưới đây:

- Viết sự kiện thay đổi icon, khi click vào button thay đổi icon:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MsgBox("Please select an icon.", MsgBoxStyle.Exclamation)
End If
If ComboBox1.SelectedItem = "" Then
MsgBox("Please select a drive letter.", MsgBoxStyle.Exclamation)
Else
My.Computer.Registry.CurrentUser.CreateSubKey("SoftwareClassesApplicationsExplorer.exeDrives" & "" & ComboBox1.SelectedItem & "" & "DefaultIcon")
My.Computer.Registry.SetValue("HKEY_CURRENT_USERSoftwareClassesApplicationsExplorer.exeDrives" & ComboBox1.SelectedItem & "" & "DefaultIcon", "", TextBox1.Text, Microsoft.Win32.RegistryValueKind.String)
MsgBox("Icon changed successfully!", MsgBoxStyle.Information)
End If
End Sub
- Viết sự kiện reset lại icon ổ đĩa mặc định của window:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If ComboBox1.SelectedItem = "" Then
MsgBox("Please select the drive letter of which you want to reset the icon.", MsgBoxStyle.Exclamation)
Else
Try
My.Computer.Registry.CurrentUser.DeleteSubKey("SoftwareClassesApplicationsExplorer.exeDrives" & ComboBox1.SelectedItem & "" & "DefaultIcon")
My.Computer.Registry.CurrentUser.DeleteSubKey("SoftwareClassesApplicationsExplorer.exeDrives" & ComboBox1.SelectedItem)
MsgBox("Success!", MsgBoxStyle.OkOnly)
Catch ex As Exception
MsgBox("That drives icon was never changed.", MsgBoxStyle.Exclamation)
End Try
End If
End Sub
Chúc các bạn thành công!
Tải project thay đổi icon ổ đĩa bằng vb.net