Solved

Programatically Disable Autoplay Window in WinForms / C#

Posted on 2010-08-28
8
1,936 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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