Documente Academic
Documente Profesional
Documente Cultură
Las capacidades del Shell se pueden ampliar con entradas de registro y archivos .ini. Si bien
este enfoque para extender el Shell es simple y adecuado para muchos propósitos, es
limitado. Por ejemplo, si usa el registro para especificar un icono personalizado para un tipo
de archivo, aparecerá el mismo icono para cada archivo de ese tipo. Extender el Shell con el
registro no le permite variar el ícono para diferentes archivos del mismo tipo. Otros aspectos
del Shell, como la hoja de propiedades Propiedades que se puede mostrar cuando se hace
clic con el botón derecho en un archivo, no se pueden modificar en absoluto con el registro.
Este documento discute cómo implementar los controladores de extensión que le permiten
modificar una variedad de acciones de Shell. Los siguientes manejadores están asociados con
un tipo de archivo en particular y le permiten especificar archivo por archivo:
Manipulador Descripción
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 1/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
Manipulador Descripción
Controlador Proporciona texto emergente cuando el usuario pasa el puntero del mouse
de infotip sobre el objeto.
Otros controladores no están asociados con un tipo de archivo en particular, pero se llaman
antes de algunas operaciones de Shell:
Manipulador Descripción
Controlador de Llamado por el Explorador de Windows antes de que muestre la vista Detalles
columna de una carpeta. Le permite agregar columnas personalizadas a la vista
Detalles.
Copiar Se llama cuando una carpeta u objeto de impresora está a punto de moverse,
manejador de copiarse, eliminarse o renombrarse. Le permite aprobar o vetar la operación.
gancho
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 2/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
Manipulador Descripción
Controlador de Se invoca cuando se arrastra un archivo con el botón derecho del mouse. Le
arrastrar y soltar permite modificar el menú contextual que se muestra.
Los detalles sobre cómo implementar controladores de extensión específicos se tratan en las
secciones enumeradas anteriormente. El resto de este documento cubre algunos problemas
de implementación que son comunes a todos los controladores de extensión de Shell.
Todos los controladores de extensión de Shell son objetos del Modelo de objetos
componentes (COM) en proceso. Se les debe asignar un GUID y registrarse como se describe
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 3/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
Como todos los objetos COM, los controladores de extensión de Shell deben implementar
una interfaz IUnknown y una fábrica de clases . La mayoría de los controladores de
extensión también deben implementar una interfaz IPersistFile o IShellExtInit en Windows
XP o versiones anteriores. Estos fueron reemplazados por IInitializeWithStream ,
IInitializeWithItem e IInitializeWithFile en Windows Vista. Shell utiliza estas interfaces
para inicializar el controlador.
Manejadores de datos
Manipuladores de caída
Implementando IPersistFile
La interfaz IPersistFile está diseñada para permitir que un objeto se cargue o se guarde en
un archivo de disco. Tiene seis métodos además de IUnknown , cinco propios, y el método
GetClassID que hereda de IPersist . Con las extensiones de Shell, IPersist se usa solo para
inicializar un objeto de controlador de extensión de Shell. Como normalmente no hay
necesidad de leer o escribir en el disco, solo los métodos GetClassID y Load requieren una
implementación no simbólica.
Shell llama primero a GetClassID , y la función devuelve el identificador de clase (CLSID) del
objeto controlador de extensión. Luego, Shell llama a Load y pasa dos valores. El primero,
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 4/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
pszFileName , es una cadena Unicode con el nombre del archivo o carpeta en el que Shell
está a punto de operar. El segundo es dwMode , que indica el modo de acceso a archivos.
Debido a que generalmente no hay necesidad de acceder a los archivos, dwMode
generalmente es cero. El método almacena estos valores según sea necesario para una
referencia posterior.
C ++ = Copiar
CSampleExtHandler::GetClassID(CLSID *pCLSID)
{
*pCLSID = CLSID_SampleExtHandler;
}
Implementando IShellExtInit
pIDFolder holds a folder's pointer to an item identifier list (PIDL). For property sheet
extensions, it is NULL. For shortcut menu extensions, it is the PIDL of the folder that
contains the item whose shortcut menu is being displayed. For nondefault drag-and-
drop handlers, it is the PIDL of the target folder.
pDataObject holds a pointer to a data object's IDataObject interface. The data object
holds one or more file names in CF_HDROP format.
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 5/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
hRegKey holds a registry key for the file object or folder type.
The IShellExtInit::Initialize method stores the file name, IDataObject pointer, and registry
key as needed for later use. The following code fragment illustrates an implementation of
IShellExtInit::Initialize. For simplicity, this example assumes that the data object contains
only a single file. In general, it might contain multiple files that will each need to be extracted.
C ++ = Copiar
STGMEDIUM medium;
FORMATETC fe = {CF_HDROP, NULL, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL};
UINT uCount;
if(SUCCEEDED(m_pDataObj->GetData(&fe, &medium)))
{
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 6/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
ReleaseStgMedium(&medium);
}
}
CSampleExtHandler is the name of the class used to implement the interface. The
m_pIDFolder, m_pDataObject, m_szFileName, and m_hRegKey variables are private
variables used to store the information that is passed in. For simplicity, this example assumes
that only one file name will be held by the data object. After the FORMATETC structure is
retrieved from the data object, DragQueryFile is used to extract the file name from the
FORMATETC structure's medium.hGlobal member. If a registry key is passed in, the
method uses RegOpenKeyEx to open the key and assigns the handle to m_hRegKey.
Infotip Customization
Implement an object that supports IQueryInfo and then register that object under the
proper subkey in the registry (see Registering Shell Extension Handlers below).
Specify a fixed string or a list of specific file properties to be displayed.
To display a fixed string for a namespace extension, create an entry called InfoTip in the
{CLSID} key of your namespace extension. Set the value of that entry to be either the literal
string you want to display, as shown in this example, or an indirect string that specifies a
resource and index within that resource (for localization purposes).
= Copiar
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 7/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
HKEY_CLASSES_ROOT
CLSID
{CLSID}
InfoTip = InfoTip string for your namespace extension
To display a fixed string for a file type, create an entry called InfoTip in the ProgID key of
that file type. Set the value of that entry to be either the literal string you want to display or
an indirect string that specifies a resource and index within that resource (for localization
purposes), as shown in this example.
= Copiar
HKEY_CLASSES_ROOT
ProgID
InfoTip = Resource.dll, 3
If you want the Shell to display specific file properties in the infotip for a specific file type,
create an entry called InfoTip in the ProgID key for that file type. Set the value of that entry
to be a semicolon-delineated list of canonical property names, format identifier
(FMTID)/property identifier (PID) pairs, or both. This value must begin with "prop:" to identify
it as a property list string. If you omit "prop:", the value is seen as a literal string and
displayed as such.
In the following example, propname is a canonical property name (such as System.Date) and
{fmtid},pid is an FMTID/PID pair.
= Copiar
HKEY_CLASSES_ROOT
ProgID
InfoTip = prop:propname;propname;{fmtid},pid;{fmtid},pid
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 8/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
OriginalLocation Location of original file Briefcase folder and Recycle Bin folder
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 9/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
Any time you create or change a Shell extension handler, it is important to notify the system
that you have made a change with SHChangeNotify, specifying the
SHCNE_ASSOCCHANGED event. If you do not call SHChangeNotify, the change might not
be recognized until the system is rebooted.
As with all COM objects, you must create a GUID for the handler using a tool such as
UUIDGEN.exe. Create a key under HKEY_CLASSES_ROOT\CLSID whose name is the string
form of the GUID. Because Shell extension handlers are in-process servers, you must create
an InProcServer32 key under the GUID key with the default value set to the path of the
handler's DLL. Use the Apartment threading model.
Any time the Shell takes an action that can involve a Shell extension handler, it checks the
appropriate registry key. The key under which an extension handler is registered thus
controls when it will be called. For instance, it is a common practice to have a shortcut menu
handler called when the Shell displays a shortcut menu for a member of a file type. In this
case, the handler must be registered under the file type's ProgID key.
Handler Names
To enable a Shell extension handler, create a subkey with the handler subkey name (see
below) under the ShellEx subkey of either the ProgID (for file types) or the Shell object type
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 10/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
For example, if you wanted to register a shortcut menu extension handler for MyProgram.1,
you would begin by creating the following subkey:
= Copiar
HKEY_CLASSES_ROOT
MyProgram.1
ShellEx
ContextMenuHandlers
For the following handlers, create a subkey underneath the "Handler Subkey name" key
whose name is the string version of the CLSID of the Shell extension. Multiple extensions can
be registered under the handler subkey name key by creating multiple subkeys.
For the following handlers, the default value of the "Handler Subkey Name" key is the string
version of the CLSID of the Shell extension. Only one extension can be registered for these
handlers.
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 11/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
The subkeys specified to add Pin to Start Menu and Pin to Taskbar to an item's shortcut
menu are only required for file types that include the IsShortCut entry.
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 12/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
The Shell defines additional objects under HKEY_CLASSES_ROOT which can be extended in
the same way as file types. For example, to add a property sheet handler for all files, you can
register under the PropertySheetHandlers key.
= Copiar
HKEY_CLASSES_ROOT
*
shellex
PropertySheetHandlers
The following table gives the various subkeys of HKEY_CLASSES_ROOT under which
extension handlers can be registered. Note that many extension handlers cannot be
registered under all of the listed subkeys. For further details, see the specific handler's
documentation.
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 13/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
Notes:
The file folder background shortcut menu is accessed by right-clicking within a file
folder, but not over any of the folder's contents.
"Verbs" are special commands registered under
HKEY_CLASSES_ROOT\Subkey\Shell\Verb .
For Network\Type\# , "#" is a network provider type code in decimal. The network
provider type code is the high word of a network type. The list of network types is given
in the Winnetwk.h header file (WNNC_NET_* values). For example, WNNC_NET_SHIVA
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 14/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
To enable a particular handler, create a subkey under the extension handler type key with the
name of the handler. The Shell does not use the handler's name, but it must be different from
all other names under that type subkey. Set the default value of the name subkey to the
string form of the handler's GUID.
El siguiente ejemplo ilustra las entradas de registro que habilitan el menú contextual y los
controladores de extensión de hoja de propiedades, utilizando un tipo de archivo de ejemplo
.myp:
= Copiar
HKEY_CLASSES_ROOT
.myp
(Default) = MyProgram.1
CLSID
{00000000-1111-2222-3333-444444444444}
InProcServer32
(Default) = C:\MyDir\MyCommand.dll
ThreadingModel = Apartment
{11111111-2222-3333-4444-555555555555}
InProcServer32
(Default) = C:\MyDir\MyPropSheet.dll
ThreadingModel = Apartment
MyProgram.1
(Default) = MyProgram Application
Shellex
ContextMenuHandler
MyCommand
(Default) = {00000000-1111-2222-3333-444444444444}
PropertySheetHandlers
MyPropSheet
(Default) = {11111111-2222-3333-4444-555555555555}
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 15/16
2/11/2019 Creación de controladores de extensión de Shell - Aplicaciones Win32 | Documentos de Microsoft
El procedimiento de registro discutido en esta sección debe seguirse para todos los sistemas
Windows.
Temas relacionados
Orientación para implementar extensiones en proceso
Yes No
https://docs.microsoft.com/en-us/windows/win32/shell/handlers 16/16