473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Play a Windows Sound

Hi There!

How do I play a sound from Windows that get played when a USB device is
plug-in or plug out?

Many thanks in advance!!

Jon
Feb 4 '07 #1
6 1030
If you're using VS 2005: My.Computer.Audio.Play("SoundFile")

"Jon B" <no*****@sorry.sorrywrote in message
news:u%****************@TK2MSFTNGP06.phx.gbl...
Hi There!

How do I play a sound from Windows that get played when a USB device is
plug-in or plug out?

Many thanks in advance!!

Jon

Feb 4 '07 #2
What type of device are you plugging in to the USB?

I wrote an application a few weeks ago that detects flash drives plugged in
to the USB ports & also alerts if the device is removed, but that is only
for flash drives, not other devices.

This was done by overriding WndProc & checking for the correct Windows
Message.

Without knowing which type of device ifs not going to be easy to help you

--
Newbie Coder
(It's just a name)


"Jon B" <no*****@sorry.sorrywrote in message
news:u%****************@TK2MSFTNGP06.phx.gbl...
Hi There!

How do I play a sound from Windows that get played when a USB device is
plug-in or plug out?

Many thanks in advance!!

Jon


Feb 5 '07 #3
Hi There,

There are no devices plugged into the computer. I just want to micmic the
sound that Windows XP plays when USB devices are plugged-in and plugged-out
in my application when my application state changes (such as switching to
Offline mode and back on...etc).

This is only as a mean for user to get the notification of my application
state by sound. No actual hardware is plugging in or out.

Cheers,
Jon

"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:uS**************@TK2MSFTNGP05.phx.gbl...
What type of device are you plugging in to the USB?

I wrote an application a few weeks ago that detects flash drives plugged
in
to the USB ports & also alerts if the device is removed, but that is only
for flash drives, not other devices.

This was done by overriding WndProc & checking for the correct Windows
Message.

Without knowing which type of device ifs not going to be easy to help you

--
Newbie Coder
(It's just a name)


"Jon B" <no*****@sorry.sorrywrote in message
news:u%****************@TK2MSFTNGP06.phx.gbl...
>Hi There!

How do I play a sound from Windows that get played when a USB device is
plug-in or plug out?

Many thanks in advance!!

Jon



Feb 5 '07 #4
Jon,

The sounds are simply .wav's that Windows stores in the C:\Windows\Media
folder. The two .wav's that you mention are 'Windows XP Hardware Insert' and
'Windows XP Hardware Remove'. You should be able to play them with little or
no trouble at all by using the Soundplayer Class in .Net 2.0. If you're
using VS 2005, just search the help for SoundPlayer.

HTH,
Bruce

"Jon B" <no*****@sorry.sorrywrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi There,

There are no devices plugged into the computer. I just want to micmic the
sound that Windows XP plays when USB devices are plugged-in and
plugged-out in my application when my application state changes (such as
switching to Offline mode and back on...etc).

This is only as a mean for user to get the notification of my application
state by sound. No actual hardware is plugging in or out.

Cheers,
Jon

"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:uS**************@TK2MSFTNGP05.phx.gbl...
>What type of device are you plugging in to the USB?

I wrote an application a few weeks ago that detects flash drives plugged
in
to the USB ports & also alerts if the device is removed, but that is only
for flash drives, not other devices.

This was done by overriding WndProc & checking for the correct Windows
Message.

Without knowing which type of device ifs not going to be easy to help you

--
Newbie Coder
(It's just a name)


"Jon B" <no*****@sorry.sorrywrote in message
news:u%****************@TK2MSFTNGP06.phx.gbl...
>>Hi There!

How do I play a sound from Windows that get played when a USB device is
plug-in or plug out?

Many thanks in advance!!

Jon




Feb 5 '07 #5
Does it have solution with VS2003?

Thanks,

Peter

Feb 5 '07 #6
No Peter, but take a look at this link. It should give you a good idea of
what you can do to play a .wav in VS2003.

http://www.gringod.com/2005/01/21/pl...urce-in-vbnet/

Bruce

"Peter" <zl*****@sina.comwrote in message
news:OV**************@TK2MSFTNGP02.phx.gbl...
Does it have solution with VS2003?

Thanks,

Peter

Feb 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: The Road To Utopia | last post by:
Here's one for the trolls...a common jibe from them is setting up audio/video hardware under linux. Ok, true story: at work today, someone asked me if I could tell him why his XP Home would play...
2
by: Keyser | last post by:
On most my pages, I use Javascript to play a sound. It works fine in Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as the operating system. However, using WindowsXP as the...
6
by: Andrew Poulos | last post by:
As a follow on to the 'fun' I had with IE I'm now trying to play sounds using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets clicked MZ says that "audObj.Play is not a function":...
2
by: NB | last post by:
I've done a thorough search, but could not find any posts If I store a sound file within the mdb, How do I play it (in a form event, for example) I can save it to a temp folder and call the...
22
by: MLH | last post by:
I have some audio help files that play fine from within Access 97 and Access 2.0. Both are running on a Windows XP box. But I do not know what program plays the files. If I click Start, Run and...
5
by: Dennis C. Drumm | last post by:
I have a windows form configured as a fixed dialog I'm using as a custom MessageBox (has some additional buttons). How do I get it to play the standard windows sounds when envoked and can I insert...
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
3
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and crackling. I'm using a couple WAVs that ship with...
5
by: | last post by:
Hello, I am wrtting a program that does some sound effects... the files are stored in a subfolder in the application folder... and I check the existence of the files before calling the method to...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.