|
Hi,
I want to know how can I force beep using C# and:
[DllImport("kernel32.dll")]
private static extern int Beep(int dwFreq, int dwDuration);
even if Microsoft Windows volume is switched to mute?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Jassim Rahma wrote: even if Microsoft Windows volume is switched to mute? That is the user's choice. I would be very annoyed if some application started beeping after I had set my PC to silent.
Use the best guess
|
|
|
|
|
The only way you can override the sound setting is to change the volume yourself, do the beep, then put the volume back where you found it. There is no little magic "override" method you can call.
The big problem with the is that you're changing a setting the user has set for a reason. THe other one is that if you turn the volume up to some arbitrary level, you have no idea how loud the sound really is. It still might not be audible or you might blast the user right out of their chair!
|
|
|
|
|
Why not use Console.Beep ?
Along with what the others say, the user may have the speakers physically turned down or off.
Or headphones could be plugged in but the user not wearing them.
There is also the possibility that the user is remoted into a system halfway 'round the world.
Perhaps you could allow the user to set a configuration setting to specify the volume to use.
For one application I wrote for a former employer I allowed the user to specify what sound to make (if any) as an alert.
|
|
|
|
|
Jassim Rahma wrote: even if Microsoft Windows volume is switched to mute?
Make sure you weld the PC-case shut. I'd rip that speaker out before you have the correct P/Invoke.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
if Microsoft Windows volume is switched to mute?
first you can change volume to 100% for playing sound and then change it back to 0%.
-Amir Mohammad Nasrollahi
/* LIFE RUNS ON CODE */
|
|
|
|