Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.Win32
- Imports System.IO
- Friend NotInheritable Class Cls_RightClic
- Friend Shared Sub Register(fileType$, shellKeyName$, menuText$, menuCommand$, Optional ByVal Arg$ = "")
- Try
- Dim regPath = String.Format("{0}\shell\{1}", fileType, shellKeyName)
- Dim newPath = menuCommand.Replace(".EXE", New FileInfo(menuCommand).Extension.ToLower)
- Using key = Registry.ClassesRoot.CreateSubKey(regPath)
- key.SetValue(Nothing, menuText)
- key.SetValue("Icon", newPath & ",0")
- End Using
- Using key = Registry.ClassesRoot.CreateSubKey(String.Format("{0}\command", regPath))
- key.SetValue(Nothing, newPath & Arg)
- End Using
- Catch ex As Exception
- MsgBox("Error : Cls_RightClic Register : " & ex.ToString)
- End Try
- End Sub
- Friend Shared Sub Unregister(fileType$, shellKeyName$)
- Try
- Dim regPath = 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("Error : Cls_RightClic UnRegister " & ex.ToString)
- End Try
- End Sub
- End Class
- '############### COMMENT L'UTILISER
- '1- Ajoutez une checkbox à votre projet
- '2- Entrez dans l'évènement "CheckedChanged" et saisir ceci :
- Private Sub ChbDesktopRightClic_CheckedChanged(sender As Object) Handles ChbDesktopRightClic.CheckedChanged
- If ChbDesktopRightClic.Checked Then
- Cls_RightClic.Register("DesktopBackground", "DNR", "Ouvrir <LE NOM DE VOTRE PROGRAMME>", Application.ExecutablePath)
- Else
- Cls_RightClic.Unregister("DesktopBackground", "DNR")
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement