Solved

Programatically Disable Autoplay Window in WinForms / C#

Posted on 2010-08-28
8
1,907 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

11 Experts available now in Live!

Get 1:1 Help Now