aj2010
asked on
Programatically Disable Autoplay Window in WinForms / C#
I have a program developed in WinForms/C# that watches for SD cards to be inserted into the computer and then does things with them. I want to disable the autoplay window when my program is running. Right now the window loads and covers over my own dialog boxes, thus confusing users when things disappear. How can I disable autoplay programatically in C#? The solution needs to work with Windows XP, Vista, and 7.
Thanks.
Thanks.
ASKER
Pop an SD card (or USB flash drive) into your machine and you'll get an AutoPlay box that Windows pops up like attached. I want to disable this.
AutoPlay.png
AutoPlay.png
Disable it in the register key set the autorun key to 0
[HKEY_LOCAL_MACHINE\SYSTEM \CurrentCo ntrolSet\S ervices\CD Rom]
"Autorun"="0"
or run this file
disable-autorun.reg
[HKEY_LOCAL_MACHINE\SYSTEM
"Autorun"="0"
or run this file
disable-autorun.reg
ASKER
Doesn't work. Note there is a difference between AutoPlay and Autorun. Also wouldn't this require a reboot? I need to disable autoplay temporarily just while my app is running.
Hi,
Please check links:
(1) https://www.experts-exchange.com/questions/20695207/Programmatically-disable-autorun-C-NET.html
(2) http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5672d4d3-2ba3-4bf4-92ea-0669514c5c2b
(3) http://stackoverflow.com/questions/2732792/can-i-disable-window-autoplay-function-programatically-with-c-net
Regards,
VSS
Please check links:
(1) https://www.experts-exchange.com/questions/20695207/Programmatically-disable-autorun-C-NET.html
(2) http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5672d4d3-2ba3-4bf4-92ea-0669514c5c2b
(3) http://stackoverflow.com/questions/2732792/can-i-disable-window-autoplay-function-programatically-with-c-net
Regards,
VSS
ASKER
Doesn't work. Perhaps this is only good for older versions of windows? I'm developing on Windows 7. I also saw the mention about this only working for the foremost window... took that into account and this doesn't seem to do anything.
hello aj
try this - works for me
try this - works for me
//RegisterWindowMessage is a Win32 API call. So you will need to use PInvoke to make it work..
using System.Runtime.InteropServices;
class Win32Call
{
[DllImport("user32.dll")]
public static extern int RegisterWindowMessage(String strMessage);
}
// In your application you will call
Win32Call.RegisterWindowMessage("QueryCancelAutoPlay");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Would you please attach a snapshot of the problem you are reporting. Actually I am not getting it correctly.
Regards,
VSS