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
|
// using Microsoft.Win32; nicht vergessen!
/// <summary>
/// Registriert ein benutzerdefiniertes URL-Protokoll für die Verwendung mit der
/// Windows-Shell, dem Internet Explorer und Office.
///
/// Beispiel für einen URL eines benutzerdefinierten URL-Protokolls:
///
/// rainbird://RemoteControl/OpenFridge/GetBeer
/// </summary>
/// <param name="protocolName">Name des Protokolls (z.B. "rainbird" für "rainbird://...")</param>
/// <param name="applicationPath">Vollständiger Dateisystem-Pfad zur EXE-Datei, die den URL bei Aufruf verarbeitet (Der komplette URL wird als Befehlszeilenparameter übergteben)</param>
/// <param name="description">Beschreibung (z.B. "URL:Rainbird Custom URL")</param>
public void RegisterURLProtocol(string protocolName, string applicationPath, string description)
{
// Neuer Schlüssel für das gewünschte URL Protokoll erstellen
RegistryKey myKey=Registry.ClassesRoot.CreateSubKey(protocolName);
// Protokoll zuweisen
myKey.SetValue(null, description);
myKey.SetValue("URL Protocol", string.Empty);
// Shellwerte eintragen
Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell");
Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open");
myKey = Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open\\command");
// Anwendung festlegen, die das URL-Protokoll behandelt
myKey.SetValue(null, "\"" + applicationPath, + "\" %1");
}
|