Simple Shell Extension to Manipulate File Summary Information

Introduction

CSimpleShlExt is a simple shell extension to manage file comments. With this extension, you can add comments to any file very easily (you right-click the file, go to Properties, and then switch to the Summary tab and add comments there) and can export the comments to clipboard in RTF, CSV, and Text formats to paste them into different applications that support these formats.

It’s a very small utility. You already know that there are many other tools available for version controlling; these give you much more facilities. The aim of this extension was to have a very small and in-place facility to add the comments and get them on demand, just through a single click.

How to Use It

This is a simple ATL project. For your convenience, go through the following steps if you haven’t created a single ATL project so far.

  1. Double-click the SimpleExt.dsw file, or open Visual C++ and open this workspace.
  2. If you don’t have Unicode libraries installed, make sure that you have selected “Win32 Release MinDependency” or “Debug” in the build toolbar.
  3. Compile the project.

That’s it; trust me. I’m not kidding. Now, right-click any file; you’ll find two new options in the context menu. They are:

  • Add Comment
  • Export Comment(s)

Now, if you click the first option (Add Comment), you’ll go directly to the Properties->Summary page to enter a file’s details. You can enter different comments to different files, and then select multiple files. Again, right-click and select the other option (Export Comment(s)). After that, launch Notepad, Excel, or Word and use Ctrl+V or paste option from the Edit menu and there you go; the comments are there for all the selected files.

Details

If you don’t want to get into the details and just want to enjoy it, you can skip this part. But if you don’t, there are two classes in this project:

  • CSimpleShlExt: It’s the main class that implements the shell extension and context menu options.
  • CFileSummary: This is the file that is used to extract the file comments.

Okay, if you go into the details, you’ll find that in NTFS, comments, and other summary details are stored into streams along with the file, but that is not same with MS-Office files, such as Word or Excel files; they are called as compound files and getting the comments stored with them is different than with other files. For further explanation, you can consult MSDN or go to www.google.com.

All the functionality of retrieving the file comments and other summary details is encapsulated in this class. You can use this class in any other project (MFC or non-MFC based as well) to get the comments of files stored. The simple way is this:

CFileSummary fs;
fs.ExtractFileSummary( "c:\myfolder\myfile.txt" );
string strComment = fs.GetComments();

Similarly, you can get other details by calling the respective functions of CFileSummary. Life is good, if things get simple, isn’t it? Enjoy!

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read