For a long time did not give the VC knowledge Base to press, really embarrassed, because the previous period of time is too busy so there has been no time to write something, there are many friends to me to discuss the issue, I am grateful to all of my support, I welcome you to continue the letter, common communication, common progress! This time I want to talk to you about Windows Shell expansion programming, first of all, before reading the following content I would like to recommend that you look at the "COM Technology Insider" this masterpiece, but even if you do not have the basic knowledge of the matter is actually irrelevant, because the following explanation is a fool-like explanation.
Development environment
Windows Professional 2000
Microsoft Visual C + + 6.0 + ATL3.0
Reference documents
COM Technology Insider
ATL Application and Development Guide (second Edition)
Windows shell Extensions
The name of the Windows shell extension in English is: Windows Shell Extension. Windows shell extensions are a special type of COM object in which users can add their own special features, and Windows shell extensions are eventually referenced by Windows Explorer. For the simplest example, a WinRar application, if you finish installing WinRar, it will add a lot of shortcut menus to your right-click menu, as shown in Figure 1.1:
Figure 1.1
The above illustration is just one of the shell extension programs: "Context Menu Handler". Is the shell extension also categorized? Yes, but not many, and their implementations are mostly consistent, and in general there are several categories:
Table (i)
Processor type |
When to trigger |
To do the processing |
Context Menu Processor |
triggered when the user right-clicks a file or folder. However, in Shell v4.71+, the user clicks the right mouse button in the margin of the folder directory to trigger the event. |
Adds a context menu item. |
Property sheet Processor |
triggered when the user right-clicks the file, selecting the File Properties menu pop-up file Properties dialog box. |
Join the User custom property page. |
Drag and Drop processors |
triggered when the user right-clicks a file or folder in a folder or desktop Drag/drop. |
Adds a context menu item. |
Drop processor |
Triggered when a data object is drag over/dropped into a file. |
Add any user-defined actions. |
QueryInfo Processor (Shell v4.71+) |
Triggered when a user hovers over a file or a Shell object. |
Add user-defined hint information (tooltips). |
Maybe someone will ask me how difficult it is to achieve them? The answer is: relatively simple. Does it have to look at the tedious ATL template classes or the stiff, inflexible MFC macro definitions? The answer is in the negative. Perhaps the above problems hinder the majority of COM beginners desire to learn, in fact, I just contact with the ATL more confusion, often complained that ATL's knowledge is too abstruse, MFC's framework is too blunt, generally I do not like to use #define to define the whole program (see effective C + +). So, let's go back to today's topic, so what are the ways to achieve the functionality shown in Figure 1.1? The answer is two, first: Registry programming. Second: Shell Extension com programming. It is very simple to implement through the registry, see the COM Component Registry implementation, where this article does not repeat the introduction, and also is not the subject of this article. In the following sections I will take the first class Shell extension programming---"Context Menu processor" as an example to explain the Handler implementation process.