using System; using System.Runtime.InteropServices; using System.IO; namespace DeviceApplication { /// /// Sound 的摘要说明。 /// string filename = Path.GetDirectoryName(Assembly.GetExecutingAssembly() /// .GetName().CodeBase) + @"/aa.wav"; /// 调用方法:Sound sound = new Sound(filename); /// 开始播放 sound.Play(); 停止播放 sound.endPlay(); public class Sound { private byte[] m_soundBytes; private string m_fileName; private enum Flags { SND_SYNC = 0x0000, /* play synchronously (default) */ SND_ASYNC = 0x0001, /* play asynchronously */ SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */ SND_MEMORY = 0x0004, /* pszSound points to a memory file */ SND_LOOP = 0x0008, /* loop the sound until next sndPlaySound */ SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */ SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */ SND_ALIAS = 0x00010000, /* name is a registry alias */ SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */ SND_FILENAME = 0x00020000, /* name is file name */ SND_RESOURCE = 0x00040004 /* name is resource name or atom */ } [DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)] private extern static int WCE_PlaySound(string szSound, IntPtr hMod, int flags); [DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)] private extern static int WCE_PlaySoundBytes(byte[] szSound, IntPtr hMod, int flags); [DllImport("CoreDll.DLL", EntryPoint = "PlaySoundW", SetLastError = true)] private extern static int PlaySoundW(string szSound, int hMod, int flags); [DllImport("CoreDll.DLL", CharSet = CharSet.Auto)] public extern static bool sndPlaySound(string lpszSoundname, uint fuSound); [DllImport("coredll")] public static extern bool PlaySound(string szSound, IntPtr hMod, int flags); public Sound(string fileName) { m_fileName = fileName; } public Sound(Stream stream) { // read the data from the stream m_soundBytes = new byte[stream.Length]; stream.Read(m_soundBytes, 0, (int)stream.Length); } /// <summary> /// 持续播放 /// </summary> public void Play() { // if a file name has been registered, call WCE_PlaySound, // otherwise call WCE_PlaySoundBytes if (m_fileName != null) WCE_PlaySound(m_fileName, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_FILENAME | Flags.SND_LOOP)); else WCE_PlaySoundBytes(m_soundBytes, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY | Flags.SND_LOOP)); } /// <summary> /// 播放一次 /// </summary> public void PlayOnce() { // if a file name has been registered, call WCE_PlaySound, // otherwise call WCE_PlaySoundBytes if (m_fileName != null) WCE_PlaySound(m_fileName, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_FILENAME | Flags.SND_NOWAIT)); else WCE_PlaySoundBytes(m_soundBytes, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY)); } /// <summary> /// 停止播放 /// </summary> public void EndPlay() { try { WCE_PlaySoundBytes(null, IntPtr.Zero, (int)(Flags.SND_SYNC | Flags.SND_MEMORY | Flags.SND_NOWAIT)); } catch (Exception e) { string str; str = e.Message; } } } }
您还没有登录,请您登录后再发表评论
适用于古老的WINCE 5.0/6.0 的基于net framework 2.0/NET CF 2.0的sqlite3.dll
Microsoft .NET CF 2.0.cab 手机上的安装包,用于无法运行NCF2.0软件的手机
在网上找了半天,没有这个东东。只好下了源代码自己编译。 现在传上来,方便大家
微软CF2.0安装程序,很多移动设备都需要。比如Symbol MC1000 移动电脑
支持.net cf 2.0 的 windows ce 6.0 emulator 模拟器,安装后可以用vs开发程序下到模拟器上查看运行结果!
DOTNETCF2.0 net精简框架2.0版
DotNET CF 2.0 下C#模拟WP7的拖拉控件方式,使用Visual Studio 2005开发
Windows Mobile 开发黄金周(3):Using SQL MOBILE on.NET CF 2.0
WPF,CF,C#,VB.Net,.Net,效率,CE .net慢,众所周之。为什么呢?控件多了就慢了。那最好办法就是减少控件数量,对于windows95的宣传动画,不知多少人还有印象,微软就是希望你看到的所有东西都是window,所以写了操作...
一个高防CF登录窗口的易语言源码 高防高防!
当在VS2005上调试PDA的程序时,需要安装的兼容器.
CF1.9.9 2.0.0 2.0.1 2.0.2 人物基址和武器基址都没变过~偏移也基本不变 不过过230的比较麻烦 基址 人物基址:21968020 死亡基址:21968012 武器基址:32764396 无限喷漆:22022656 队友伤害:21910528 全图变白:...
此安装程序数据库中包含安装 Microsoft .NET Compact Framework 2.0 所需的逻辑和数据
cfspc2_0_compact_flash、cfspc3_0_compact_flash The information in this specification is subject to change without notice. Use of this specification for product design requires an executed license ...
资源分类:Python库 所属语言:Python 资源全名:cf-python-2.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
强大的易语言CF(穿越火线)源码+模块
CF 协议 规范 compact flash specification ver 2.0
自用的CF包,包含了2.0与3.5,WinCE端需要的基本都有,有需要的就下载吧
易语言cf登陆器源码,下载分很少,仿真超高
相关推荐
适用于古老的WINCE 5.0/6.0 的基于net framework 2.0/NET CF 2.0的sqlite3.dll
Microsoft .NET CF 2.0.cab 手机上的安装包,用于无法运行NCF2.0软件的手机
在网上找了半天,没有这个东东。只好下了源代码自己编译。 现在传上来,方便大家
微软CF2.0安装程序,很多移动设备都需要。比如Symbol MC1000 移动电脑
支持.net cf 2.0 的 windows ce 6.0 emulator 模拟器,安装后可以用vs开发程序下到模拟器上查看运行结果!
DOTNETCF2.0 net精简框架2.0版
DotNET CF 2.0 下C#模拟WP7的拖拉控件方式,使用Visual Studio 2005开发
Windows Mobile 开发黄金周(3):Using SQL MOBILE on.NET CF 2.0
WPF,CF,C#,VB.Net,.Net,效率,CE .net慢,众所周之。为什么呢?控件多了就慢了。那最好办法就是减少控件数量,对于windows95的宣传动画,不知多少人还有印象,微软就是希望你看到的所有东西都是window,所以写了操作...
一个高防CF登录窗口的易语言源码 高防高防!
当在VS2005上调试PDA的程序时,需要安装的兼容器.
CF1.9.9 2.0.0 2.0.1 2.0.2 人物基址和武器基址都没变过~偏移也基本不变 不过过230的比较麻烦 基址 人物基址:21968020 死亡基址:21968012 武器基址:32764396 无限喷漆:22022656 队友伤害:21910528 全图变白:...
此安装程序数据库中包含安装 Microsoft .NET Compact Framework 2.0 所需的逻辑和数据
cfspc2_0_compact_flash、cfspc3_0_compact_flash The information in this specification is subject to change without notice. Use of this specification for product design requires an executed license ...
资源分类:Python库 所属语言:Python 资源全名:cf-python-2.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
强大的易语言CF(穿越火线)源码+模块
CF 协议 规范 compact flash specification ver 2.0
自用的CF包,包含了2.0与3.5,WinCE端需要的基本都有,有需要的就下载吧
易语言cf登陆器源码,下载分很少,仿真超高