¿Cómo se agrega un elemento al menú contextual de una carpeta?

¿Cómo se agrega un elemento al menú contextual de una carpeta?

Sé cómo agregar un menú contextual para cuando haces clic en una carpeta real:

[HKEY_CLASSES_ROOT\Directory\shell\commandNameHere]

pero ¿qué pasa con hacer clic en nada?en una carpeta?

Como hago una nueva carpeta en mi escritorio, hago doble clic para ingresar a la carpeta, luego hago clic derecho en nada (la carpeta está vacía), ahora quiero que mi menú contextual aparezca en esta situación.

Respuesta1

Para cualquiera interesado, aquí está el .regarchivo para agregar esta funcionalidad al menú contextual de Windows:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Shell]
@="none"
[HKEY_CLASSES_ROOT\Directory\shell\gitBashHere]
[HKEY_CLASSES_ROOT\Directory\Background\shell\gitBashHere]
"Icon"="C:\\icons\\git-gui.ico"
"MUIVerb"="git bash here"
"Position"="bottom" 
[HKEY_CLASSES_ROOT\Directory\shell\gitBashHere\command] 
[HKEY_CLASSES_ROOT\Directory\Background\shell\gitBashHere\command]
@="C:\\Program Files\\Console2\\Console.exe -d %v"

(Tomado decomentario de xero)

Esto agrega un comando al menú contextual llamado "git bash aquí" con un ícono, que abre una consola.

El comando se agrega en ambos:

  • HKEY_CLASSES_ROOT\Directory\shell, el menú contextual al hacer clic derecho en una carpeta
  • HKEY_CLASSES_ROOT\Directory\background, el menú contextual cuando haces clic derecho en el espacio vacío "de fondo" mientras estás en una carpeta

Respuesta2

void WriteContextMenu(LPSTR key, LPSTR value) {

HKEY hkey=0; DWORD disp;

if(RegCreateKeyEx(HKEY_CLASSES_ROOT, key, 0, NULL, REP_OPTION_NON_VOLATILE, KEY_WRITE,NULL, &hkey, &disp)!=ERROR_SUCCESS) 

{

     if(RegOpenKey(HKEY_CLASSES_ROOT,key,&hkey)!=ERROR_SUCCESS)
    {   

      cout<<"Unable to open Registry"<<key;

        }

}if(RegSetValueEx(hkey,TEXT(""),0,REG_SZ,(LPBYTE)value, strlen(value)*sizeof(char))!=ERROR_SUCCESS)

{

   RegCloseKey(hkey);

       cout<<"Unable to set Registry Value ";

} else{

   cout<<value<<" value has set"<<endl;
}
}int main(){LPSTR key="Folder\\shell\\Testing_App"; 

 LPSTR valueKey="Menu_Title";

 LPSTR Subkey="Folder\\shell\\Testing_App\\command";


/*Here put the path or action you want to perform like you want to
    open cmd  on your context menu so the value id */

    LPSTR valueSubKey="cmd.exe";

    WriteContextMenu(key, ValueKey); 
    WriteContextMenu(Subkey, ValueSubKey);

return 0;}

Respuesta3

Aquí hay una solución para todos los menús contextuales.

https://stackoverflow.com/questions/20449316/how-add-context-menu-item-to-windows-explorer-for-folders/20458056#20458056

Pero, cómo pasar varios directorios o archivos a este menú contextual como argumentos, ya que %1 toma solo uno y cuando presionamos Ctrl+clic en varios archivos, abre el ejecutable varias veces en lugar de enviarlos todos como argumentos.

información relacionada