0

I'm trying to process the Ctrl+Z ( Undo Delete ) context menu action in my namespace extension, but I'm having trouble finding a way to do this.

I see in the doc that one needs to implement FM_UNDELETE_PROC, but no details on how to register this callback. Also tried to set a Shell hook, but no relevant messages arrive there.

Any thoughts? Also, how would one register a delete operation so the explorer would allow the Undo to take place. Now it appears if I do this from another location.

Thanks, David

1 Answers1

1

Windows has per process (prior to Vista) or global file operation stack. If you use API functions like SHFileOperation or IFileOperation interface you can pass FOF_ALLOWUNDO flag BUT this flag is ignored if the source file parameter does not contain fully qualified path and file names. It means if you want use system file operation stack your shell extension objects MUST have SFGAO_FILESYSTEM attribute and you MUST return valid file path and name when IShellFolder.GetDisplayNameOf is called with SHGDN_FORPARSING parameter. Also it is necessary to implement ITransferSource and ITransferDestination interfaces. So if objects don`t not have SFGAO_FILESYSTEM attribute you must use your own implementation of operation stack.

Undo Delete command in background context menu of folder or in Edit menu is system command and it has no any relation to your shell extension. And you should not process the Ctrl+Z manually.

Denis Anisimov
  • 3,297
  • 1
  • 10
  • 18
  • Thanks for the response, Denis. I've stumbled upon ITransferSource and ITransferDestination in my research, but I see that these are only supported from Vista, so it's not possible to achieve this behaviour on XP, right? David – David Cristian Feb 20 '14 at 09:33
  • Sorry, but I did not test the feature you need on XP. I will do it some later and write about results. – Denis Anisimov Feb 20 '14 at 10:12
  • XP solution (not tested, just theory): if your items have SFGAO_FILESYSTEM attribute they are associated with real files. So just use SHFileOperation with real files and with FOF_ALLOWUNDO flag. After user delete file shell will add record to undo stack and Undo Delete operation will be available. You must monitor folders of your files with SHChangeNotifyRegister. When user run Undo Delete shell restore file from Recycle Bin and you can catch restoring event. – Denis Anisimov Feb 20 '14 at 17:40