views:

263

answers:

1

I have code that ads both Autoplay and WIA handlers for reading images files from memory cards and digital cameras, respectively, and it works fine.

However, I'd like to reset the Autoplay and WIA handlers to the default of "Ask me what to do every time" the first time my application is run. Why? Because if the user has the handlers set to something else then when s/he tries to use my application, their machine will still do the something else and then s/he will complain to me that my application doesn't work when in fact their machine is simply honoring their previous settings.

So is there any way to reset both Autoplay and WIA handlers programatically? I assume there's either some API call (preferably Win32 and not .Net) or registry setting(s) that can be modified.

A: 

It looks like the per-user autoplay preferences (what corresponds to the Autoplay control panel in Windows Vista and 7) are kept under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\UserChosenExecuteHandlers. There's a subkey for each category of autoplay device or media type; changing the subkey's default value to MSPromptEachTime should restore the "Ask me what to do every time" behavior. (Although the Autoplay control panel is new to Vista and 7, the same registry keys exist in XP, and for volume-based autoplay, I think they work the same.)

This MSDN article has more details on how autoplay works.

Josh Kelley