How can I override or customize the delete confirmation dialog in Windows?
When we press Shift+Delete key, a delete confirmation dialog is generated. I want to handle this dialog according my need or change its message. Can anyone tell me what thing is responsible for that dialog?
I either need to know the code which handles the delete confir开发者_运维问答mation dialog generated by the Shift+Delete key sequence in Windows XP, or the code by which we can control this operation.
I don't think what you want to do is going to be fun.
Im guessing you have to intercept the SHFileOperation function (and the IFileOperation interface for Vista onward)
Here what my google-fu got me on winapi interception: http://www.codeproject.com/kb/system/hooksys.aspx
You might want to look at this : http://easyhook.codeplex.com/
This project supports extending (hooking) unmanaged code (APIs) with pure managed ones, from within a fully managed environment like C# using Windows 2000 SP4 and later...
Good Luck! =)
If you only want to mess with the dialog (change the displayed text, image, etc.) you can try to modify the resources with a free tool such as Resource Hacker.
The "delete" dialog resources are in shell32.dll in Windows XP (you mentioned only that version of Windows); fire up the Resource Hacker and open shell32.dll, then search for the warning text "Are you sure you want to delete" and you'll find:
CONTROL "Are you sure you want to delete '%1'?", 12295, STATIC, SS_LEFT | SS_NOPREFIX | WS_CHILD | WS_VISIBLE | WS_GROUP, 41, 10, 220, 28
Now that's only the static text, but the whole dialog definition (buttons etc.) should be here. I think this way you can make it a simple warning dialog--e.g. "You're forbidden to delete anything!" and only a "Cancel" button.
One way to address file deletion restrictions could be by employing NTFS security descriptors.
- Security Descriptors
- Security Descriptor Operations
That way, you change it in one place and not have to worry about covering all cases to prevent deleting a file.
精彩评论