感谢您使用微软的产品。关于如何从资源文件中播放声音,您可以参考下边的代码:[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))。