Æ÷ź Namespace ¿¬Àå: ÁÖ¹® »ç·É¼± ǰ¸ñ Ãß°¡
°³°ü
³ª¿¡¼ ´õ À̸¥ Æ÷½ºÆ®, ³ª´Â °úÅ IShellView ½Ç½Ã (ÀÏÄþî DefView)¸¦ »ç¿ëÇÏ¿© Æ÷ź Namespace ¿¬ÀåÀ» âÁ¶ÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÖ¾ú´Ù. ´ç½ÅÀÌ °ßº»¿¡¼ ÁÖÀÇÇÒÁöµµ ¸ð¸¥ 1°³ÀÇ °ÍÀº »ç·É¼±ÀÌÀÇ °øÇã °úÅ ǰ¸ñ°ú °°Àº "Æí¼ºÇÑ´Ù"¿Í "Àü¸Á"ÀÌ´Ù ÀÌ´Ù.
´ç½ÅÀÌ ´ç½ÅÀÇ ÀÚ½ÅÀÇ Namespace¸¦ °³¹ßÇÏ°í ±×¸®°í µðÆúÆ® ¹öưÀ» Æ÷ÇÔÇϰí´Â °ÍÀ» ±×¸®°í/¶ÇÇÑ »ç·É¼±¿¡ ´ç½ÅÀÇ ÀڽмººÐÀ» ¶ÇÇÑ Ãß°¡ÇÏ°í ½ÍÀº °æ¿ì¿¡, ´ç½ÅÀº ¾î¶»°Ô À̰ÍÀ» ´Þ¼ºÇϴ°¡? ÀÀ´ä: ´ç½ÅÀº ½ÇÇàÇØ¾ß ÇÑ´Ù IExplorerCommand, IExplorerCommandProvider ±×¸®°í IEnumExplorerCommand °ø¿ë¿µ¿ª.
³ª´ÂÀÇ ¹Ø¿¡ °ø¿ë¿µ¿ªÀÇ °¢°¢ÀÌ »ç¿ëµÇ°í ¹«½¼À» À§ÇØ Á¦´ë·Î ´ç½ÅÀÇ ºÎÈ£¿¡¼ ±×µéÀ» ½ÇÇàÇϱâ À§ÇÏ¿© ´ç½ÅÀÌ Çʿ䰡 ÀÖ´Â ¹«½¼À» ±â¼úÇÑ´Ù ÇÒ.
IExplorerCommandProvider
´ç½ÅÀÇ Namespace°¡ ÀûÀçµÈ ÈÄ¿¡, Æ÷źÀº IExplorerCommandProviderÀÇ °æ¿ì¸¦ ´ç½ÅÀÇ Namespace¸¦ ¿ä±¸ÇÒ °ÍÀÌ´Ù. ÀÌ °ø¿ë¿µ¿ªÀº 2°³ÀÇ ¹æ¹ýÀ» µå·¯³½´Ù: GetCommand¿Í GetCommands. Æ÷źÀº GetCommand °ø±ÞÇÑ GUID¿Í ÀÏÄ¡ÇÏ´Â IExplorerCommand ƯÁ¤ÇÑ ¸ñÇ¥¸¦ ¸¸È¸Çϱâ À§ÇÏ¿© ¹æ¹ýÀ» ºÎ¸¥´Ù (°¢ ¸í·ÉÀº GUID¿¡ ÀÇÇØ È®ÀεȴÙ). GetCommands ¹æ¹ýÀº IEnumExplorerCommand °æ¿ì¸¦ ¸¸È¸Çϱâ À§ÇÏ¿© ºÒ¸°´Ù. ÀÌ ¸ñÇ¥´Â namespace¸¦ À§ÇÑ IExplorerCommand ¸ðµç °æ¿ì¸¦ ¿°ÅÇÑ´Ù.
´ç½ÅÀº ±×°ÍÀÇ IShellFolderÀÇ CreateViewObjectÀÇ ½Ç½Ã¸¦ ÅëÇØ IExplorerCommandProviderÀÇ ±×°ÍÀÇ ½Ç½Ã¸¦ À§ÇØ Namespace Áú¹®µÈ´Ù. CreateViewObject¿¡ Åë°úµÈ REFIID´Â IID_IExplorerCommandProviderÀÏ °ÍÀÌ´Ù. Æ÷źÀº ±× ¶§ ÀÌ ¸¸È¸Çϱâ À§ÇÏ¿© °ø¿ë¿µ¿ªÀ»ÀÇ ½Ç½ÃÀÎ ´ç½ÅÀÇ »ç·É¼± ǰ¸ñ ÀÌ¿ëÇÒ °ÍÀÌ´Ù IExplorerCommand °ø¿ë¿µ¿ª.
IExplorerCommand
IExplorerCommand °ø¿ë¿µ¿ªÀº ŽÇè°¡ÀÇ »ç·É¼±¿¡ ǰ¸ñÀÇ ¿Ü°ü ±×¸®°í ÇൿÀ» Á¦°øÇϱâ À§ÇÏ¿© ÀÌ¿ëµÈ´Ù. ¹æ¹ýÀÇ ´ëºÎºÐÀº ǰ¸ñÀÌ Àü¸Á¿¡¼ ÇöÀç ¼±Á¤µÇ´Â ¹«½¼À» È®ÀÎÇÏ´Â IShellItemArray¸¦ Åë°úÇÑ´Ù. ÀÌ Á¤º¸´Â ½Ç½Ã¿¡ ÀÇÇØ ¾Æ¹« ǰ¸ñµµ ¼±Á¤µÇÁö ¾Ê´Â °æ¿ì¿¡ ¶Ç´Â ´Ù¸¥ ¼±ÅÃÀ» À§ÇÑ ÇൿÀ» ÁÖ¹®À» ¹Þ¾Æ¼ ¸¸µé±â À§ÇÏ¿© ÀÌ¿ëµÉ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¸é, ¾Æ¹« ǰ¸ñµµ ¼±Á¤µÇÁö ¾Ê´Â °æ¿ì¿¡, ´ç½ÅÀº, °¢°¢ ±¹°¡¸¦ ECS_DISABLED ¶Ç´Â ECS_HIDDEN¿¡ ȸ»ö ¹ÛÀ¸·Î¿¡ ³õ°Å³ª »ç·É¼±¿¡¼ ǰ¸ñÀ» ¿ÏÀüÇÏ°Ô Á¦°ÅÇÒ ¹Ù¶ö ¼öµµ ÀÖ´Ù.
ÀÌ °ø¿ë¿µ¿ª¿¡ ÀÇÇØ µå·¯³½ ¹æ¹ýÀº ¾Æ·¡¿¡ ±â¼úÇÑ ¹Ù¿Í °°´Ù.
|
¹æ¹ý |
¹¦»ç |
|
EnumSubCommands |
ÇöÀç ¸í·ÉÀÇ ÀÌÇÏ ¸í·ÉÀ» ¿°ÅÇÏ´Â ÀÌ¿ëµÈ IEnumExplorerCommand °æ¿ì¸¦ µ¹·Áº¸³½´Ù. Æ÷źÀº ´ÜÁö GetFlags ¹æ¹ýÀÌ ECF_HASSUBCOMMANDS¸¦ µ¹·Áº¸³»´Â °æ¿ì¿¡ ÀÌ ¹æ¹ý¸¸ ºÎ¸¦ °ÍÀÌ´Ù. ÀÌ·¸°Ô ÇÏ´Â °ÍÀÌ °¡´ÉÇÑ µ¿¾È, ÀÌÇÏ ¸í·É ±×µéÀÚ½ÅÀÌ ÀÖ´Â ÀÌÇÏ ¸í·É¿¡´Â °Ý·ÁµÇÁö ¾Ê´Â´Ù´Â °ÍÀ» ÁÖ¿¡ ¿©±â¿¡¼ Áß¿äÇÏ´Ù. |
|
GetCanonicalName |
ÀÌ ¸í·É°ú °ü·ÃµÇ¾ú´ø ¼¼°èÀûÀ¸·Î À¯ÀÏÇÑ Àνıâ (GUID)¸¦ ¸¸È¸ÇÑ´Ù |
|
GetFlags |
ÀÌ ¸í·É°ú °ü·ÃµÇ¾ú´ø ±ê¹ßÀ» ¸¸È¸ÇÑ´Ù. ÀÌ ±ê¹ßÀº »ç·É¼±¿¡ ¸í·ÉÀÇ ¿Ü°ü ±×¸®°í ÇൿÀ» ÁöÁ¤ÇÑ´Ù. |
|
GetIcon |
¾ÆÀÌÄÜ ÀÚ¿ø ²öÀ» ¸¸È¸ÇÑ´Ù. ÀÌ ²öÀº "myfile.dll, I.DÀÇ ¸ð¾çÀ¸·Î" ÀÌ´Ù. ¿¹¸¦ µé¸é: ¡°shell32.dll,-101¡± |
|
GetState |
Retrieves the state of the command item. This is the first method of the interface that is called. The state that is returned affects the appearance and behavior of the command item. This method also passes a BOOL to let the command implementation know if the slow response rule is in effect. |
|
GetTitle |
Retrieves the string to display for the command item. |
|
GetToolTip |
Retrieves the string to use in the ToolTip associated with this command item. |
|
Invoke |
Called by the Shell when the user has activated a command on the Commands Module. |
The above methods GetState and GetFlags return values that determine the appearance and behavior of the item in the Command Module. In the table below are screenshots of the command resulting from the combinations of the flags/states values.
|
|
ECS_ENABLED |
ECS_DISABLED |
ECS_HIDDEN |
|
NONE |
|
|
|
|
ECF_HASSUBCOMMANDS |
|
|
|
|
ECF_HASSPLITBUTTON |
|
|
|
|
ECF_HIDELABEL |
|
|
|
|
ECF_ISSEPARATOR |
|
N/A |
|
|
ECF_HASLUASHIELD |
|
|
|
|
|
ECS_CHECKBOX |
ECS_CHECKBOX| ECS_CHECKED |
|
NONE |
|
|
|
ECF_HASSUBCOMMANDS |
|
|
|
ECF_HASSPLITBUTTON |
|
|
|
ECF_HIDELABEL |
|
|
|
ECF_ISSEPARATOR |
N/A |
N/A |
|
ECF_HASLUASHIELD |
|
|
*ECS_CHECKBOX and ECS_CHECKED only apply to sub items
** ECF_ISSEPARATOR can only be added as a sub item
Slow Response Rule
The second parameter of the GetState method is a BOOL (fOkToBeSlow) that lets the implementation of IExplorerCommand know if the ¡°slow response rule¡± is in effect. If this value is FALSE, and your implementation performs slow operations (such as I/O, network calls or calls to out of thread COM objects) then your command should return E_PENDING. This will cause the Commands Module to call the command¡¯s GetState (and other methods) on a background thread with fOkToBeSlow set to TRUE. This prevents slow operations in your implementation from running on the UI thread, thus preventing performance issues.
Command Item Ordering
It is important to note here that the developer of the Namespace Extension has no control over the ordering of command items. For example, you cannot force your command items before the default View and Organize command items or have the View or Organize command items renamed/removed. Items are simply appended to the end of the Commands Module in the order returned from the IEnumExplorerCommand instance.
IEnumExplorerCommand
The IEnumExplorerCommand is returned to the Shell by the GetCommands method of the IExplorerCommandProvider interface. As the name suggests, it permits enumeration of the IExplorerCommand instances by the Shell.
FolderViewImpl Sample Code
The above interfaces have been implemented in the attached Shell Namespace Extension sample code derived from the FolderViewImpl SDK sample. The structure of the command items (as well as sub items) is data-driven from an array of structures that define the command items (see the array of FVCOMMANDITEMs in fvcommands.cpp). This approach was used to make it easy to experiment with the hierarchy of command items as well as their behavior/appearance. The way you implement commands in your Namespace Extension may differ.
The above is a screenshot of the modified SDK sample. Notice we now have the default command items (Organize and Views) as well as our custom items. The Display command item performs the same function as right-clicking items in the view and selecting ¡°Display¡± from the context menu. The Settings button is used to demonstrate a command item with sub items. All it does is display a message box with the name of the sub item when the user invokes the specified sub item.
It should also be noted that if you are using a custom view in your Namespace by implementing your own IShellView (instead of using DefView) you will need to include an implementation of IFolderView::GetFolder. In your GetFolder implementation you will need to include the ability to QueryService for SID_SFolderView.
Building the FolderView SDK Sample
- To build the FolderViewImpl sample, be sure to download and install the Windows SDK.
- Download the modified FolderView SDK sample
- Launch FolderViewImpl.sln in Visual Studio
- Open the properties for the project
- Add a path to the SDK includes to the C/C++ - General page
- Add a path to the SDK libs to the Linker – General page
- Build
Installing the FolderView SDK Sample
- Once you have built the sample, copy the FolderViewImpl.dll and FolderViewImpl.propdesc to the same directory
- From an elevated cmd window, regsvr32 FolderViewImpl.dll
- Restart explorer
- Open explorer to Computer
- There should be a list item named ¡°FolderView SDK Sample¡±
Written by chrdavis. Read more great feeds at is source WEBSITE
no comments.
Read more articles on shell and namespace and Coding and API and Programming and vista and Windows Vista.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article














