感谢您使用微软的产品。关于如何从资源文件中播放声音,您可以参考下边的代码:[DllImport("winmm.dll",EntryPoint="sndPlaySound")]
public static extern bool sndPlaySound(ref Byte snd,int fuSound);//将第一个参数类型改成ref Byte
private static System.Byte[] sound;Assembly thisAssembly = Assembly.GetAssembly(Type.GetType("resSound.Form1"));
ResourceManager rm= new ResourceManager("resSound.sound",thisAssembly);
sound=(System.Byte[])rm.GetObject("Chimes");
System.Byte[] snd =new System.Byte[sound.GetLength(0)];
sndPlaySound(ref sound[0],0x04);//将参数改成0x04将从内存中读取文件- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
public static extern bool sndPlaySound(ref Byte snd,int fuSound);//将第一个参数类型改成ref Byte
private static System.Byte[] sound;Assembly thisAssembly = Assembly.GetAssembly(Type.GetType("resSound.Form1"));
ResourceManager rm= new ResourceManager("resSound.sound",thisAssembly);
sound=(System.Byte[])rm.GetObject("Chimes");
System.Byte[] snd =new System.Byte[sound.GetLength(0)];
sndPlaySound(ref sound[0],0x04);//将参数改成0x04将从内存中读取文件- 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
解决方案 »
- 求使C#winform webBrowser execScript变成字符串,获得UBB文本编辑器的值。
- c# winform 调用Lotus Notes客户端发邮件
- 大家教教我在VS2008中怎么反编译C#代码啊
- C#对注册表操作应该注意什么?
- 页面传值,接收字符不完整,为什么?
- TREEVIEW与datagridview数据联动问题!急,在线等
- 请教一个Double.ToString()的问题,求解答 速结分
- .net问题,急急急急急急急急,有高分相送
- 请问怎么关闭C#compiler中的这个warning?
- win me下面没有办法打开datagrid??跟xml有关系?先谢谢了
- 请MVP帮助。如何取得DataGrid当前行的行值,及用button删除当前行的方法?
- 微软大哥们救救我好吗?快来不及了,今天就要交工阿。可怎么办啊。
1。System.Byte[] snd =new System.Byte[sound.GetLength(0)];一句去掉完全没有问题,播放正常。
2。sndPlaySound(ref sound[0],0x04);//将参数改成0x04将从内存中读取文件,此种播放方式为同步的,即一定要等到放完了,才能继续下面的程序运行。将此句改为:
sndPlaySound(ref sound[0],0x05);
就可以即从内存中读取文件,又是异步播放。