1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Imports Microsoft.Win32
Imports System.IO
Namespace Settings
Friend NotInheritable Class RightClic
Private Shared Sub Register(fileType$, shellKeyName$, menuText$, menuCommand$, Optional ByVal Arg As String = "")
Dim regPath As String = String.Format("{0}\shell\{1}", fileType, shellKeyName)
Dim newPath$ = menuCommand.Replace(".EXE", New FileInfo(menuCommand).Extension.ToLower)
Using key As RegistryKey = Registry.ClassesRoot.CreateSubKey(regPath)
key.SetValue(Nothing, menuText)
key.SetValue("Icon", newPath & ",0")
End Using
Using key As RegistryKey = Registry.ClassesRoot.CreateSubKey(String.Format("{0}\command", regPath))
key.SetValue(Nothing, newPath & Arg)
End Using
End Sub
Private Shared Sub Unregister(fileType$, shellKeyName$)
Try
Dim regPath As String = String.Format("{0}\shell\{1}", fileType, shellKeyName)
If Not Registry.ClassesRoot.OpenSubKey(regPath, True) Is Nothing Then
Registry.ClassesRoot.DeleteSubKeyTree(regPath)
End If
Catch ex As Exception
MsgBox("RightClic UnRegister")
End Try
End Sub
End Class
End Namespace |