[VB.NET] Code Change ICO Ỗ Đĩa PC

Hôm nay mình xin hướng dẫn các bạn một ứng dụng mới của mình đó là "CHANGE ICO Ổ ĐĨA" một cách đơn giản mà không cần hiểu rỏ về máy tính. :D


Nhìn sơ qua thì các bạn cũng biết thêm gì rồi chứ :D, mình cũng không nói rỏ thêm nữa :D hoặc các bạn cũng có thể Download Full bộ SOURCE bên dưới về và tìm hiểu rỏ nhé :D

FULL CODE

Public Class Form1
Dim image As System.Drawing.Image
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.SelectedItem = "C"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
End Sub

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("Software\\Classes\\Applications\\Explorer.exe\\Drives" & "\\" & ComboBox1.SelectedItem & "\\" & "DefaultIcon")
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Classes\Applications\Explorer.exe\Drives\" & ComboBox1.SelectedItem & "\" & "DefaultIcon", "", TextBox1.Text, Microsoft.Win32.RegistryValueKind.String)
MsgBox("Icon changed successfully!", MsgBoxStyle.Information)
End If
End Sub

Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
End Sub

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("Software\Classes\Applications\Explorer.exe\Drives\" & ComboBox1.SelectedItem & "\" & "DefaultIcon")
My.Computer.Registry.CurrentUser.DeleteSubKey("Software\Classes\Applications\Explorer.exe\Drives\" & 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

Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
PictureBox2.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
End Sub
End Class

Hướng dẫn sơ qua: Bạn muốn thay đỗi hình ảnh ổ đĩa thì các bạn có thể tìm kiếm 1 file ảnh dạng "HINHANH.ICO" đó là đuôi "*.ICO" và các bạn thêm vào ứng dụng và chọn ổ đĩa muốn thay đỗi và ấn vào button thay đỗi ico là các bạn đã thay đỗi thành công rồi đó :D chúc các bạn thành công :D

Video DEMO cho các bạn :p



DOWNLOAD FILE EXE DOWNLOAD SOURCE

Chúc các bạn thành công. Và các bạn cũng lưu ý dùm mình là nếu copy bài viết này thì các bạn làm phiền dẫn nguồn về trang bài viết này nhé, để tôn trọng tác giả :D


Đăng nhận xét