How can I override or customize the delete confirmation dialog in Windows?

偶尔善良 提交于 2019-12-13 17:42:48

问题


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 confirmation dialog generated by the Shift+Delete key sequence in Windows XP, or the code by which we can control this operation.


回答1:


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! =)




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/4394988/how-can-i-override-or-customize-the-delete-confirmation-dialog-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!