Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

With this C # code I extend my file explorer in such a way that an additional menu point appears in the context menu of the right mouse button to photos, videos, folder directories,

Which starts my additional app / WPF application.

The program should then list a directory with all photos and videos, so that you can rearrange them into subfolders.

 

 

 

C # Code to create additional menus 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 >---------

 

 

 

And the executing method as a separate class

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

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de