beep in WinCE , it possible ?

帅比萌擦擦* 提交于 2019-12-05 09:37:44
JaredPar

The .net framework methods for beeing are not available in the CF version of the framework. The best way to get a beep sound is to PInvoke into the MessageBeep function. The PInvoke signature for this method is pretty straight forward

[DllImport("CoreDll.dll")]
public static extern void MessageBeep(int code);

public static void MessageBeep() {
  MessageBeep(-1);  // Default beep code is -1
}

This blog post has an excellent more thorough example: http://blog.digitforge.com/?p=4 (on archive.org)

Yes. P/Invoke PlaySound or sndPlaySound or MessageBeep. See this or this or this. It's amazing what 30 seconds with a search engine can turn up.

If you're looking to play one of the default system sounds and using .net runtime 2.0+ (and framework v 3.5+), then you can use the System.Media.SystemSounds class (no need for PInvoke or WinAPI calls), like so:

//available system sounds
System.Media.SystemSounds.Asterisk.Play();
System.Media.SystemSounds.Beep.Play();
System.Media.SystemSounds.Exclamation.Play();
System.Media.SystemSounds.Hand.Play();
System.Media.SystemSounds.Question.Play();

Note that the user won't hear anything if they have disabled or muted system sounds.

However, if you are looking to play an arbitrary tone, then the above answers involving WinAPI or PInvoke are what you need to look at.

For a simple beep in Compact Framework you don't need all that import nonsense. Besides, depending on the hardware you'll only have access to the default beep anyway. Just use:

Microsoft.VisualBasic.Interaction.Beep()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!