Click here to Skip to main content
Licence 
First Posted 7 Jan 2001
Views 103,392
Downloads 1,019
Bookmarked 30 times

'Copy To' & 'Move To' in Shell Context Menu.

By Mumtaz Zaheer | 7 Jan 2001
This article is all about how to create a context menu shell extension. 'Copy To' & 'Move To' will be added to the files/folder context menu.
1 vote, 16.7%
1
1 vote, 16.7%
2

3
1 vote, 16.7%
4
3 votes, 50.0%
5
4.09/5 - 48 votes
μ 4.09, σa 3.06 [?]

Sample Image - ContMenuExt.gif

Introduction

In Win2K you can see two new tool bar buttons in Windows Explorer: Copy To & Move To. Yet Microsoft hasn't realized to include these two entries in files/folders context menu. I wish for these entries in context menu because every time for copying or moving files/folders, I have to change the folders or have to push those new tool bar buttons in Win2K.

Following example will create those two entries in context menu.

I assume that you are familiar of creating shell extensions, COM, clipboard operation and Shell APIs. (Esposito Dino's book is very handy for any beginner shell programmer).

Follow all steps that are required to create a shell extension.

Following keys in registry will tell shell that, you are extending the files/folders context menu. Those are:

#define SZ_DIRCONTEXTMENUEXT  
  _T("Directory\\shellex\\ContextMenuHandlers\\Mumtaz")
#define SZ_FILECONTEXTMENUEXT  
  _T("*\\shellex\\ContextMenuHandlers\\Mumtaz")
#define SZ_FOLDERCONTEXTMENUEXT  
  _T("Folder\\shellex\\ContextMenuHandlers\\Mumtaz")

Don't be confused with text Mumtaz; that's my Name.

When user views the context menu of file/folders, shell starts the game of looking for any one who is extending the shell. That will include the difficult words like DllGetClassObject, IClassFactory, DllMain...

My concern is to tell you about IContextMenu, not all of it but Intialize and InvokeCommand.

First Initialize, it has the following prototype:

IContextMenu::Initialize (LPCITEMIDLIST pidlFolder, 
        LPDATAOBJECT lpdobj, HKEY hKeyProgID);

Our concern is the LPDATAOBJECT. We can retrieve the list of files/folders being selected through this data object pointer. This includes FORMATETC for clipboard format and STGMEDIUM for storage medium. You can study these two structures in detail on MSDN. We put the files/folders being selected, in a class member m_pszSource.

In Invoke command, we do the rest of the operation, yes, copying or moving. SHBrowseForFolder() help us for selecting destination, that will be a PIDL. We must convert it to a string for passing it to SHFileOperation as a destination path.

That's all.

I haven't included any details for creating shell extension, because you can read much about it on MSDN. For clipboard format and data object search try "Handling Shell Data Transfer Scenarios" on MSDN.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mumtaz Zaheer

Web Developer

Pakistan Pakistan

Member
Mumtaz Zaheer is working as Senior System Analyst with Information Architects, Pakistan (http://www.info-architects.com/).

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to creat menu on the basis of file extensions. Pinmemberstudentkth1:55 20 Oct '09  
AnswerRe: How to creat menu on the basis of file extensions. PinmemberMumtaz Zaheer2:13 20 Oct '09  
Generaladd menu for image files only Pinmemberkiranin20:02 1 Nov '06  
QuestionRemoving "Select" menu item from right click context menu on files and folders PinmemberReji_Kumar0:20 15 Dec '05  
GeneralGreat Article Madame PinmemberThatsAlok21:02 27 Oct '04  
GeneralGet *.lnk File Path PinmemberMiss Fress19:37 5 Apr '04  
QuestionHow can i recover it Pinmembersophialili19:54 24 Mar '04  
AnswerRe: How can i recover it PinmemberMumtaz Zaheer21:59 24 Mar '04  
GeneralRe: How can i recover it Pinmemberzhgfhz12:56 5 Jun '06  
Generalthank's Pinmembericrmio22:57 13 Mar '03  
Generalfile copying Pinsusswolfs-bane0:18 7 Nov '02  
Questionwhat is the difference PinmemberAnonymous3:22 20 Jul '01  
AnswerRe: what is the difference PinsussAnonymous3:21 28 Aug '02  
GeneralRe: error on IID_IShellExtInit and IID_IContextMenu PinmemberMumtaz Zaheer19:29 22 Jan '01  
GeneralCreating popup (sub menu)for Copy to PinmemberkevinDougla15:13 18 Jan '01  
GeneralRe: Creating popup (sub menu)for Copy to PinmemberMumtaz Zaheer18:45 22 Jan '01  
GeneralRe: Creating popup (sub menu)for Copy to PinmemberMumtaz Zaheer23:52 12 Feb '01  
GeneralWin2k already supports this PinmemberMatthew Ellis4:11 8 Jan '01  
GeneralRe: Win2k already supports this PinmemberSteven J. Ackerman4:29 8 Jan '01  
GeneralRe: Win2k already supports this PinmemberMumtaz Zaheer0:58 9 Jan '01  
GeneralRe: Win2k already supports this PinmemberAnonymous21:00 22 Jan '01  
GeneralRe: Win2k already supports this PinmemberAnonymous0:30 13 Oct '01  
GeneralRe: Win2k already supports this PinmemberAnonymous19:48 17 Feb '02  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120209.1 | Last Updated 8 Jan 2001
Article Copyright 2001 by Mumtaz Zaheer
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid