Skip to content

Commit f137079

Browse files
committed
Remove redundant registry key
1 parent d58662e commit f137079

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

Installer/PasteIntoFile.wxs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@
108108
<RegistryValue Type='string' Value='"[INSTALLFOLDER]PasteIntoFile.exe" copy "%V"'/>
109109
</RegistryKey>
110110
</RegistryKey>
111-
<RegistryKey Key='Background\shell\PasteIntoFile'>
112-
<RegistryValue Type='string' Value='Copy file content'/>
113-
<RegistryValue Type='string' Name='Icon' Value='"[INSTALLFOLDER]PasteIntoFile.exe",0'/>
114-
<RegistryKey Key='command'>
115-
<RegistryValue Type='string' Value='"[INSTALLFOLDER]PasteIntoFile.exe" copy "%V"'/>
116-
</RegistryKey>
117-
</RegistryKey>
118111
</RegistryKey>
119112
</Component>
120113
</Fragment>

PasteIntoFile/RegistryUtil.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ namespace PasteIntoFile
88
{
99
public class RegistryUtil
1010
{
11-
// Please note that registry keys are also created by installer
12-
// and removed upon uninstall
11+
// Please note that registry keys are also created by installer and removed upon uninstall
12+
// Always keep the "Installer/PasteIntoFile.wxs" up to date with the keys used below!
13+
1314

1415
private static string PRIMARY_KEY_NAME = "PasteIntoFile";
16+
17+
/// <summary>
18+
/// Opens a number of class sub keys according to the requested type.
19+
/// Passing type=null (default) will return all keys for all types
20+
/// </summary>
21+
/// <param name="type">Class type, one of "Directory", "*" or null</param>
22+
/// <returns>List of registry keys</returns>
1523
private static IEnumerable<RegistryKey> OpenClassKeys(string type = null) {
16-
if (type == null) // return all class type keys (dirs and files)
17-
{
18-
return OpenClassKeys("Directory").Concat(OpenClassKeys("*"));
19-
}
20-
var node = Registry.CurrentUser.CreateSubKey(@"Software\Classes\" + type);
21-
return new[] {
22-
node.CreateSubKey(@"Background\shell"),
23-
node.CreateSubKey(@"shell"),
24-
} ;
24+
var classes = Registry.CurrentUser.CreateSubKey(@"Software\Classes");
25+
var keys = new List<RegistryKey>();
26+
if (type == null || type == "Directory")
27+
keys.AddRange(new [] {classes.CreateSubKey(@"Directory\shell"), classes.CreateSubKey(@"Directory\Background\shell")});
28+
if (type == null || type == "*")
29+
keys.Add(classes.CreateSubKey(@"*\shell"));
30+
return keys;
2531
}
2632

2733

0 commit comments

Comments
 (0)