Hi!
Ich will das MenuItem beim WindowsExplorer hinzufügen und dann wird mein Programm gestartet und dann möchte ich den Link der Bilddatei haben.
Wie mach ich das? Der Code fügt einfach nichts hinzu.
Spoiler anzeigen
Ich will das MenuItem beim WindowsExplorer hinzufügen und dann wird mein Programm gestartet und dann möchte ich den Link der Bilddatei haben.
Wie mach ich das? Der Code fügt einfach nichts hinzu.
VB.NET-Quellcode
- Imports Microsoft.Win32
- Public Class ContextAdder
- ''' <summary>
- ''' Fügt dem Kontextmenü des Windows Explorers einen Eintrag für einen Dateityp hinzu.
- ''' Bei Erfolg wird True zurückgegeben, sonst False.
- ''' </summary>
- ''' <param name="extension">Der Dateityp. Beispiel: .txt</param>
- ''' <param name="text">Der Text des Eintrags. Beispiel: In JSEdit öffnen</param>
- ''' <param name="command">Der aufzurufende Befehl. Beispiel: C:\jsedit.exe "%1"</param>
- Public Shared Function AddToExplorerContextMenu(ByVal extension As String, _
- ByVal text As String, ByVal command As String) As Boolean
- ' Beispiel der Kommentare:
- ' extension=.js
- ' text=In JSEdit öffnen
- ' command= C:\jsedit.exe "%1"
- Try
- ' Öffnen: HKEY_CLASSES_ROOT\.js
- Dim Extensionkey As RegistryKey = Registry.ClassesRoot.CreateSubKey(extension)
- ' Öffnen: HKEY_CLASSES_ROOT\.js\Shell
- Dim Shellkey As RegistryKey = Extensionkey.CreateSubKey("Shell")
- ' Öffnen: HKEY_CLASSES_ROOT\.js\Shell\In JSEdit bearbeiten
- Dim Entrykey As RegistryKey = Shellkey.CreateSubKey(text)
- ' Öffnen: HKEY_CLASSES_ROOT\.js\Shell\In JSEdit bearbeiten\command
- Dim Commandkey As RegistryKey = Entrykey.CreateSubKey("command")
- Commandkey.SetValue("", command)
- Commandkey.Close()
- Entrykey.Close()
- Shellkey.Close()
- Extensionkey.Close()
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- End Class
Whos Faster ALPHA: Bald....