#

 

 

Mit diesem C# Code erweitere ich meinen Datei-Explorer in der Weise, dass beim Kontextmenü der rechten Maustaste zu Fotos, Videos, Ordner-Verzeichnissen jeweils ein zusätzlicher Menü-Punkt erscheint,

welcher meine zusätzliche App/ WPF Anwendung startet.

Das Programm soll anschliessend ein Verzeichnis mit allen Fotos und Videos auflisten, damit man diese in Unterordner umsortieren kann.

 

 

 

C# Code zum erstellen der zusätzlichen Menüs in Windows 10

#region ---------< Region: Buttons >---------

        private void btnRegister_Context_Click(object sender, RoutedEventArgs e)

        {

            //--------< btnRegister_Context_Click() >--------

            //*add additional Context-Menu in File-Explorer for: Folders, Images, Videos, right-click on background of folder

            String app_Key = "GroupInSubfoldersByDate";

            String menu_Title = "≡ SubFolders → Images @byDate";

            String app_Fullname_with_Path = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + System.AppDomain.CurrentDomain.FriendlyName;

 

            //--< Folder >--

            String menu_Path = "Folder\\shell" + "\\" + app_Key;

            clsRegistry.add_Menu_of_App(menu_Path, menu_Title, app_Fullname_with_Path," %1" );

            //--</ Folder >--

 

            //--< Images > --

            menu_Path = "SystemFileAssociations\\image\\shell" + "\\" + app_Key;

            clsRegistry.add_Menu_of_App(menu_Path, menu_Title, app_Fullname_with_Path, " %1");

            //--</ Images > --   

           

            //--< Videos > --

            menu_Path = "SystemFileAssociations\\.mov\\shell" + "\\" + app_Key;

            clsRegistry.add_Menu_of_App(menu_Path, menu_Title, app_Fullname_with_Path, " %1");

            menu_Path = "SystemFileAssociations\\.mp4\\shell" + "\\" + app_Key;

            clsRegistry.add_Menu_of_App(menu_Path, menu_Title, app_Fullname_with_Path, " %1");

            //--</ Videos > --   

 

            //--< Background > --

            menu_Path = "Directory\\Background\\shell" + "\\" + app_Key;

            clsRegistry.add_Menu_of_App(menu_Path, menu_Title, app_Fullname_with_Path, " %V");

            //--</ Background > --

            //--------</ btnRegister_Context_Click() >--------

        }

 

        private void btnUnRegister_Context_Click(object sender, RoutedEventArgs e)

        {

            //--------< btnUnRegister_Context_Click() >--------

            //*remove additional Context-Menu in File-Explorer for: Folders, Images, Videos, right-click on background of folder

 

            String app_Key = "GroupInSubfoldersByDate";

            String registry_Menu_Path = "Folder\\shell" + "\\" + app_Key;

            clsRegistry.fxRegistry_Remove_Key(registry_Menu_Path);

 

            registry_Menu_Path = "SystemFileAssociations\\image\\shell" + "\\" + app_Key;

            clsRegistry.fxRegistry_Remove_Key(registry_Menu_Path);

 

            registry_Menu_Path = "SystemFileAssociations\\.mov\\shell" + "\\" + app_Key;

            clsRegistry.fxRegistry_Remove_Key(registry_Menu_Path);

 

            registry_Menu_Path = "SystemFileAssociations\\.mp4\\shell" + "\\" + app_Key;

            clsRegistry.fxRegistry_Remove_Key(registry_Menu_Path);

 

            registry_Menu_Path = "Directory\\Background\\shell" + "\\" + app_Key;

            clsRegistry.fxRegistry_Remove_Key(registry_Menu_Path);

            //--------</ btnUnRegister_Context_Click() >--------

        }

        #endregion ---------</ Region: Buttons >---------

 

 

 

Und die ausführende Methode als separate Classe

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

//--< using >--

using Microsoft.Win32;                     //Registry

using WinForms = System.Windows.Forms;     //Messagebox

//--</ using >--

 

namespace Group_Images_By_Date

{

    static class clsRegistry

    {

 

        public static void add_Menu_of_App(String registry_Menu_Path, String registry_Menu_Title, String app_Fullname_with_Path, string add_parameter="")

        {

            //----------------< fxRegistry_Install_Key() >----------------

            RegistryKey regMenu = null;

            try

            {

                regMenu = Registry.ClassesRoot.CreateSubKey(registry_Menu_Path);

 

                if (regMenu != null)

                {

                    regMenu.SetValue("", registry_Menu_Title);

                    regMenu.SetValue("Icon", app_Fullname_with_Path + ",0" );

                    

                    //< command >

                    RegistryKey regCommand = Registry.ClassesRoot.CreateSubKey(registry_Menu_Path + "\\command");

                    regCommand.SetValue("", app_Fullname_with_Path + add_parameter);

                    regCommand.Close();

                    //</ command >

                }

            }

            catch (Exception ex)

            {

                WinForms.MessageBox.Show("Error in Registration: " + ex.Message);

            }

 

            finally

            {

                if (regMenu != null)regMenu.Close();                   

            }

            //----------------</ fxRegistry_Install_Key() >----------------

        }

 

       

        public static void fxRegistry_Remove_Key(String registry_Menu_Path)

        {

            //----------------< fxRegistry_Remove_Key() >----------------

            try

            {

                Registry.ClassesRoot.DeleteSubKeyTree(registry_Menu_Path);

            }

            catch (Exception ex)

            {

                WinForms.MessageBox.Show(ex.ToString());

            }

            //----------------</ fxRegistry_Remove_Key() >----------------

        }

    }

}

 

 

 

Mobile

.

123movies