使用 PlaySound 在移动设备上播放声音文件。此代码使用 System.Runtime.InteropServices
调用 Compact Framework 的 CoreDll.DLL 的 PlaySound 方法
关于播放实现:
//播放标志
private enum Flags
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_NODEFAULT = 0x0002,
SND_MEMORY = 0x0004,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_ALIAS = 0x00010000,
SND_ALIAS_ID = 0x00110000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}
[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private extern static int MobilePlaySound(string szSound, IntPtr hMod, int flags);
public void PlaySound(string fileName)
{
MobilePlaySound(fileName, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_FILENAME));
}
关于停止实现:
PlaySound(null);
关于PlaySound函数:
一.PlaySound函数的声明为:
BOOL PlaySound(LPCSTR pszSound,HMODULE hmod,DWORD fdwSound);
1.参数pszSound:是指定了要播放声音的字符串,该参数可以是WAVE文件的名字,或是WAVE资源的名字,或是内存中声音数据的指针,或是在系统注册表WIN.INI中定义的系统事件声音.如果该参数为NULL则停止正在播放的声音.
2.参数hmod:是应用程序的实例句柄,当播放WAV资
原先一直用BinaryFormatter来序列化挺好,可是最近发现在WinCE下是没有办法进行BinaryFormatter操作,很不爽,只能改成了BinaryWriter和BinaryReader来读写,突然想到能不能用XML来序列化?于是在网上查了些资料便写了些实践性代码,做些记录,避免以后忘记。
序列化对象
public class People
......