Click here to Skip to main content
15,890,897 members
Articles / Desktop Programming / WTL
Article

Shell Extension using ATL and WTL

Rate me:
Please Sign up or sign in to vote.
3.40/5 (4 votes)
18 Mar 2001CPOL 118.2K   1.4K   29   17
Shell extension that extends the Windows Explorer user interface

Sample Image - ShellServer.gif

Introduction

Here is another Shell extension sample - the one which extends Windows Explorer's user interface.

Let me note that my sample does not do anything useful - I'll try to think of something later - it just shows how to write this kind of shell extension.

How to install it?

Copy the ShellServer.dll to any directory of your choice and register it using regsvr32.exe. Next time when you open the Windows Explorer you'll see one more folder in the left pane tree - Shell Server. Just click on it and you'll see it in action.

a ShellServer integrates its own menu, toolbar buttons, text in the status bar with Windows Explorer and displays a listview control in the right pane of Explorer with some data.

There are 4 classes in the project:

  • CFolderObj which implements IShellFolder and IPersistFolder interfaces.
  • CViewObj which implements IShellView interface.
  • CMainDlg
  • CShellListView

CFolderObj
and CViewObj are implemented using ATL, CMainDlg and CShellListView use WTL.

The implementation is pretty straightforward, except for one thing - if you want to handle window messages in the listview control you have to create the modeless dialog first and place a listview control on it.

I wrote it on WinNT 4.0 sp6 and did not test on Win95/98.

That's it. Enjoy it and use it any way you want. Do not even mention my name (I am a very modest person).

Credits - www.clipcode.com

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralDrag and drop Pin
HarvinderSinghChaddha18-May-07 2:22
HarvinderSinghChaddha18-May-07 2:22 
GeneralRe: Drag and drop Pin
Igor Vigdorchik18-May-07 12:02
Igor Vigdorchik18-May-07 12:02 
QuestionHow to change tool bar items and menu items Pin
kil ramesh17-Jan-06 23:57
kil ramesh17-Jan-06 23:57 
GeneralAdding Toolbar Buttons to Explorer Pin
iffi9928-May-03 21:29
iffi9928-May-03 21:29 
GeneralRe: Adding Toolbar Buttons to Explorer Pin
Igor Vigdorchik9-May-03 10:42
Igor Vigdorchik9-May-03 10:42 
GeneralRe: Adding Toolbar Buttons to Explorer Pin
Sardaukar21-Sep-03 0:04
Sardaukar21-Sep-03 0:04 
You have to implement a shell namespace extension.

There is a variety of shell extensions: shortcut menu, data, drop, icon, icon overlay, property sheet, column, copy hook, drag-and-drop, search, disk cleanup - all these are 'handlers'.
Almost all these are simple COM objects, implementing just IClassFactory and specific interfaces for the extension type - for example, a column handler will need to implement (minimally) IColumnProvider, an icon handler will implement IExtractIcon and IPersistFile, a context menu handler will implement IContextMenu and so on.

However, for implementing toolbar buttons (and not only) you need to implement a IShellBrowser, so the prime choice is the shell namespace.

The boundary betwenn various kind of extensions is flexible, so is perfectly possible to implement a mixed kind of extension - let's say you are integrating your archiver into Explorer and implement in the same dll:
- context menu functionality for right click on your archive file type;
- data handler extension for clipboard format operations;
- icon handler;
- drag-and-drop;
- the namespace for browse and handle directly in Explorer the content of your archive file, so opening your archive will be just another folder in the shell.

There is also another way to add a toolbar button - but will work on relatively newer platforms, meaning that a Windows NT 4.0 SP1 with IE 3.0 won't support it: Browser Helper Objects (BHO). Think on integration of FlashGet, MSN Messenger, AOL Instant Messenger etc. in Internet Explorer's toolbar - these are all BHOs.
If you choose this way, you have to decide where it will be supported (in Windows Explorer, Internet Explorer, or both), implement the required functionality and register you COM object. (I didn't wrote any BHO's for use in Windows Explorer, just for Internet Explorer - but I suppose is perfectly possible).

The ugliest choice - but the best concerning integration, extensibility and power - is the shell namespace. There are quite a number of such articles on various sites (unfortunately, a good part of them are offline or does not exists anymore now), but MSDN contains a good number of samples of each kind (look also in older MSDN, 1999 or so!). Once started, it shouldn't be that bad Smile | :) .

Happy debugging the namespace ! Big Grin | :-D
GeneralFile Open Pin
gnichola11-Oct-01 13:11
gnichola11-Oct-01 13:11 
Generalgood stuff. btw: the toolbar icons in xp are 24x24... Pin
28-Sep-01 9:11
suss28-Sep-01 9:11 
GeneralRe: good stuff. btw: the toolbar icons in xp are 24x24... Pin
Igor Vigdorchik4-Oct-01 11:18
Igor Vigdorchik4-Oct-01 11:18 
GeneralRe: good stuff. btw: the toolbar icons in xp are 24x24... Pin
13-Nov-01 8:55
suss13-Nov-01 8:55 
GeneralRe: good stuff. btw: the toolbar icons in xp are 24x24... Pin
Igor Vigdorchik15-Nov-01 3:47
Igor Vigdorchik15-Nov-01 3:47 
QuestionHandling ? Pin
15-Jun-01 4:27
suss15-Jun-01 4:27 
AnswerRe: Handling ? Pin
Igor Vigdorchik20-Jun-01 13:17
Igor Vigdorchik20-Jun-01 13:17 
Questionatlapp.h missing ? Pin
19-Mar-01 21:59
suss19-Mar-01 21:59 
AnswerRe: atlapp.h missing ? Pin
20-Mar-01 4:59
suss20-Mar-01 4:59 
AnswerRe: atlapp.h missing ? Pin
Tanya Petrone20-Mar-01 6:13
Tanya Petrone20-Mar-01 6:13 
GeneralRe: atlapp.h missing ? Pin
20-Mar-01 22:14
suss20-Mar-01 22:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.