How do I prevent users from dragging and dropping files in Explorer?

Raymond Chen

More than once, I’ve had a customer ask, “How do I prevent users from dragging and dropping files in Explorer?” Actually, three of them in the past year phrased it in an even more provocative way: “I want to write a program that hooks Explorer and displays a prompt before every drag/drop operation.” This is one of those cases where you have to figure out what the customer really wants. They’ve solved half of their problem and are asking you for help with the other half. In my experience so far, when customers ask this question, their real problem is always one of the following: First, they just want to prevent the user from moving files into or out of directories that the users shouldn’t be modifying. In other words, the question isn’t “How do I prevent users from dragging and dropping files in Explorer?” but rather “How do I prevent users from moving files I don’t want them to move, and to prevent them from moving files into directories I don’t want them to modify?” The answer to the customer’s real question is not to try to block the user interface operation (because, even if you block it there, they can still move the file around by other means, like say, the command prompt) but rather to apply ACLs to the underlying files and directories so that the users don’t have permission to perform the operation you want to block. Another common response to “Please explain why you think you need to do this” is “Well, I find that my users will accidentally move files around when they didn’t mean to. They might be clicking on a file, but accidentally drag the mouse while clicking, resulting in the file being dropped into a folder by mistake.” In other words, the real question is “How do I prevent users from performing accidental drag and drop operations?” The answer to this customer’s real question is to increase the mouse drag sensitivity (via System­Parameters­Info(SPI_SETDRAGWIDTH) and SPI_SETDRAGHEIGHT) to require uses to drag the mouse a “definitely not accidental” distance before the system considers a drag operation to be in progress. Depending on your users, you might crank this up to 10, 30, or even 60 pixels.

[Raymond is currently away; this message was pre-recorded.]

0 comments

Discussion is closed.

Feedback usabilla icon