You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to develop a shell extension via SharpShell in windows 11 following the demo "CountLines" in this CodeProject Article. I copied the code and build it in Release mode, everything works fine by now.
Then, I tried several methods to deploy the generated dll, such as regasm, srm or ServerManager, each method works. However, the Context Menu for txt files doesn't have a "CountLines" item. By the way, it works fine in ServerManager.exe test shell.
Then, I used ShellexView to check my extension, it does exist but its file path shows:
"C:\Windows\System32\D:/my/custom/path/shellext.dll" Why does this happen?
Here is my code and some results:
usingSystem.IO;usingSystem.Runtime.InteropServices;usingSystem.Text;usingSharpShell;usingSharpShell.SharpContextMenu;usingSharpShell.Attributes;usingSystem.Windows.Forms;/// <summary>/// The CountLinesExtensions is an example shell context menu extension,/// implemented with SharpShell. It adds the command 'Count Lines' to text/// files./// </summary>[ComVisible(true)][COMServerAssociation(AssociationType.ClassOfExtension,".txt")]publicclassCountLinesExtension:SharpContextMenu{/// <summary>/// Determines whether this instance can a shell/// context show menu, given the specified selected file list/// </summary>/// <returns>/// <c>true</c> if this instance should show a shell context/// menu for the specified file list; otherwise, <c>false</c>/// </returns>protectedoverrideboolCanShowMenu(){// We always show the menureturntrue;}/// <summary>/// Creates the context menu. This can be a single menu item or a tree of them./// </summary>/// <returns>/// The context menu for the shell context menu./// </returns>protectedoverrideContextMenuStripCreateMenu(){// Create the menu stripvarmenu=newContextMenuStrip();// Create a 'count lines' itemvaritemCountLines=newToolStripMenuItem{Text="Count Lines...",};// When we click, we'll count the linesitemCountLines.Click+=(sender,args)=>CountLines();// Add the item to the context menu.menu.Items.Add(itemCountLines);// Return the menureturnmenu;}/// <summary>/// Counts the lines in the selected files/// </summary>privatevoidCountLines(){// Builder for the outputvarbuilder=newStringBuilder();// Go through each file.foreach(varfilePathinSelectedItemPaths){// Count the linesbuilder.AppendLine(string.Format("{0} - {1} Lines",Path.GetFileName(filePath),File.ReadAllLines(filePath).Length));}// Show the outputMessageBox.Show(builder.ToString());}}
I'm trying to develop a shell extension via SharpShell in windows 11 following the demo "CountLines" in this CodeProject Article. I copied the code and build it in Release mode, everything works fine by now.
Then, I tried several methods to deploy the generated dll, such as regasm, srm or ServerManager, each method works. However, the Context Menu for txt files doesn't have a "CountLines" item. By the way, it works fine in ServerManager.exe test shell.
Then, I used ShellexView to check my extension, it does exist but its file path shows:
"C:\Windows\System32\D:/my/custom/path/shellext.dll" Why does this happen?
Here is my code and some results:
ServerManager.exe test shell
Install shellext server in ServerManager.exe
Weird filename in shellexview
However, in registry, its path seems right?
I have tried to use srm or regasm to register the dll, both of them show the same result.
The text was updated successfully, but these errors were encountered: