Solved

Programatically Disable Autoplay Window in WinForms / C#

Posted on 2010-08-28
8
1,926 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:aj2010
8 Comments
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33548821
Hi,

Would you please attach a snapshot of the problem you are reporting. Actually I am not getting it correctly.

Regards,
VSS
0
 

Author Comment

by:aj2010
ID: 33548875
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
0
 
LVL 2

Expert Comment

by:IngCharlie
ID: 33548972
Disable it in the register key set the autorun key to 0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CDRom]
"Autorun"="0"

or run this file

disable-autorun.reg
0
 

Author Comment

by:aj2010
ID: 33549066
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33549139
0
 

Author Comment

by:aj2010
ID: 33549208
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.
0
 
LVL 6

Expert Comment

by:r3nder
ID: 33550346
hello aj
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"); 

Open in new window

0
 
LVL 15

Accepted Solution

by:
Russell_Venable earned 500 total points
ID: 33551731
Here is the example you are looking for.
 http://www.pinvoke.net/default.aspx/user32.registerwindowmessage
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now