Неверное имя файла для расширения оболочки, установленного SharpShell в Win11.C#

Место общения программистов C#
Ответить
Anonymous
 Неверное имя файла для расширения оболочки, установленного SharpShell в Win11.

Сообщение Anonymous »

Я пытаюсь разработать расширение оболочки с помощью SharpShell в Windows 11, следуя демонстрации «CountLines» в этой статье CodeProject. Я скопировал код и собрал его в режиме выпуска, теперь все работает нормально.
Затем я попробовал несколько методов развертывания сгенерированной dll, таких как regasm, srm или ServerManager, каждый метод работает. Однако в контекстном меню для текстовых файлов нет пункта «CountLines». Кстати, в тестовой оболочке ServerManager.exe оно работает нормально.
Затем я использовал ShellexView, чтобы проверить свое расширение, оно существует, но путь к его файлу показывает:
"C :\Windows\System32\D:/my/custom/path/shellext.dll" Почему это происходит?
Вот мой код и некоторые результаты:

Код: Выделить всё

using System.IO;
using System.Runtime.InteropServices;

using System.Text;

using SharpShell;
using SharpShell.SharpContextMenu;
using SharpShell.Attributes;

using System.Windows.Forms;

/// 
/// The CountLinesExtensions is an example shell context menu extension,
/// implemented with SharpShell. It adds the command 'Count Lines' to text
/// files.
/// 
[ComVisible(true)]
[COMServerAssociation(AssociationType.ClassOfExtension, ".txt")]
public class CountLinesExtension : SharpContextMenu
{
/// 
/// Determines whether this instance can a shell
/// context show menu, given the specified selected file list
/// 
/// 
/// true if this instance should show a shell context
/// menu for the specified file list; otherwise, false
/// 
protected override bool CanShowMenu()
{
//  We always show the menu
return true;
}

/// 
/// Creates the context menu. This can be a single menu item or a tree of them.
/// 
/// 
/// The context menu for the shell context menu.
/// 
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 count the lines
itemCountLines.Click += (sender, args) => CountLines();

//  Add the item to the context menu.
menu.Items.Add(itemCountLines);

//  Return the menu
return menu;
}

/// 
/// Counts the lines in the selected files
/// 
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 output
MessageBox.Show(builder.ToString());
}
}
Тестовая оболочка ServerManager.exe
Установите сервер Shellext в ServerManager.exe
Странное имя файла в Shellexview< /p>
Однако в реестре путь кажется правильным?
Я пытался использовать srm или regasm для регистрации dll, оба они показывают одно и то же результат.

Подробнее здесь: https://stackoverflow.com/questions/793 ... l-in-win11
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»