すべての「jpg」ファイルの Windows エクスプローラーのコンテキスト メニューにコンテキスト メニュー項目を追加したいと考えています。ユーザーがこれをクリックすると、コンテキスト メニュー項目の名前は「process JPEG」になり、メインの実行可能ファイルが呼び出されます。問題は私はすでにメインのc#実行可能ファイルを作成しており、コンテキストメニューからのみ実行するのではなく、独立して実行できます。ユーザーがコンテキストメニューコマンドを選択してクリックしたファイル名またはファイル名をメインの実行可能ファイルに渡したいので、メインの実行可能ファイルが何らかの方法を使用してファイルを取得し、それらを処理できるようになることを確認します。コンテキスト メニューを統合するために次のことを行いました-助けてください
public static void Register(
string fileType, string shellKeyName,
string menuText, string menuCommand)
{
Debug.Assert(!string.IsNullOrEmpty(fileType) &&
!string.IsNullOrEmpty(shellKeyName) &&
!string.IsNullOrEmpty(menuText) &&
!string.IsNullOrEmpty(menuCommand));
// create full path to registry location
string regPath = string.Format(@"{0}\shell\{1}", fileType, shellKeyName);
// add context menu to the registry
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(regPath))
{
key.SetValue(null, menuText);
}
// add command that is invoked to the registry
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(
string.Format(@"{0}\command", regPath)))
{
key.SetValue(null, menuCommand);
}
}