Play a Windows Sound

  • Thread starter Thread starter Jon B
  • Start date Start date
J

Jon B

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