Solved

Programatically Disable Autoplay Window in WinForms / C#

Posted on 2010-08-28
8
1,956 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

749 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