Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Whenever a user select one or more files or folders in windows explorer and right click to cut or copy the selected objects,
i have to disable pop up menu's cut and and copy options for particular type of files(i.e for file having .doc extension , pop up menu should not display cut or copy options).


Ya, i know that i have to process WM_INITMENUPOPUP message.
but how could i know what is currently selected in Window explorer application.

I don't know ,what window-extra-memory of windows explorer does contain?

from where i can get list of objects selected so as i can correctly process WM_INITMENUPOPUP ?

Can any one give me guidance?

Thanks in Advance.
Posted

This should provide you with a walk-through: Use Shell Context Menu in your applications[^].

Note some things: it has nothing or almost nothing to do with "extra Windows memory"; I have no idea why you consider these concerns related. Right term for the menu is "Context menu". Prefer disabling of the items to hiding them. No, it will affect not just the Windows Explorer but any file manager or any other code based on Shell API — be aware of it. Some file managers will have different commands added to the Context Menu, like "Move" in one step. There are many other ways to manipulate file, using the console, first of all. See also the notes by Nishant he posted in his Solution.

That said, if you think your Context Menu can provide some kind of file protection, think again: it won't, whatever you do with the Shell.

Finally, I'm not sure you really need to do this work (unless you want to register really serious application to work via Shell interface; a very successful example is such approach is TortoiseSVN, http://en.wikipedia.org/wiki/TortoiseSVN[^]).

If a Word document is opened, it cannot be deleted/moved anyway as Word keeps it open without shared access. If you simply use Word automation, it will always behave like that. In all other cases, you can do the same.

—SA
 
Share this answer
 
v3
Comments
Espen Harlinn 18-Apr-11 17:44pm    
Nice reply, 5ed!
Sergey Alexandrovich Kryukov 18-Apr-11 22:16pm    
Thank you, Espen.
--SA
Zubin 2 20-Apr-11 3:10am    
Thanking you both for your reply
Sergey Alexandrovich Kryukov 20-Apr-11 12:59pm    
You're very welcome.
Are you going to formally accept the solution?
Thank you.
--SA
Zubin 2 21-Apr-11 2:50am    
No, i am not accepting the solution based on Shell Context Menu because context menu will not provide me the prevention of cutting and copying a file of particular type(also you have told me in your valuable reply--thanking you for that).

Thus, I focused on
1> Manipulating clipboard for when user select cut/copy from context menu
2> Manipulating IDataObject object for dragged scenario.

I have implemented manipulation of clipboard successfully.
I have almost done to cover up dragged scenario with little problem as i documented at codeproject with subject:"Is there any documented way to filter dragged data?"

kindly read it.

Thanking you for your interest in solving my problem.
[Adding to SA's response.]

Merely disabling copy/cut in the context menus won't help prevent people from copying the file. They can use keyboard shortcuts. They can use a console app to do it, or do it programatically by specifying the full path. They can copy a parent folder that contains the document. In fact by mapping the drive across a network, they can do it across the network from another machine. Keep this in mind too.
 
Share this answer
 
Comments
Espen Harlinn 18-Apr-11 17:45pm    
Good point, my 5
Sergey Alexandrovich Kryukov 18-Apr-11 22:17pm    
You're absolutely right, I should have mentioned that myself (I'll reference this post by updating my solution).
My 5.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900