I tried to implement a custom ShellExtension in Windows 8.1. Found that really good SharpShell tutorial.
[ComVisible(true)]
[COMServerAssociation(AssociationType.AllFiles)]
public class CountExtProvider : SharpContextMenu
{
protected override bool CanShowMenu()
{
// We will always show the menu.
return true;
}
protected override ContextMenuStrip CreateMenu()
{
// Create the menu strip.
var menu = new ContextMenuStrip();
// Create a 'count lines' item.
var itemCountLines = new ToolStripMenuItem
{
Text = "Count Lines"
};
// When we click, we'll call the 'CountLines' function.
itemCountLines.Click += (sender, args) => CountLines();
// Add the item to the context menu.
menu.Items.Add(itemCountLines);
// Return the menu.
return menu;
}
private void CountLines()
{
// Builder for the output.
var builder = new StringBuilder();
// Go through each file.
foreach (var filePath in SelectedItemPaths)
{
// Count the lines.
builder.AppendLine(string.Format("{0} - {1} Lines",
Path.GetFileName(filePath), File.ReadAllLines(filePath).Length));
}
// Show the ouput.
MessageBox.Show(builder.ToString());
}
}
I am in a Windows 8.1 RTM x64 environment, so I changed my build plattform to x64 in Visual Studio 2013 RC. Added a Key-File to sign my *.dll. But if I want to register my *.dll nothing happends:
regasm ShellExtensions.dll
The command line says registering was successful but in the context menu there is no entry. What I am doing wrong here? Does this work with Windows 8.1 no more?