C# 使用PlaySound在移动设备上播放声音
使用 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资
相关文档:
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......
1)Xml文档示例(xmlsample.xml):
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
<song title="Oh,girl">
<artist>The Chi-lites</artist>
<genre>Soul</genre>
&nb ......
public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAcces ......
这本书讲解
C#
语言十分详细,我将其中的重要内容整理成条款,以备忘。
1.
事件是在满足某个特定条件时发生的,触发
(raise)
事件的对象称为发布者
(publisher)
,对这个事件进行响应的对象称为订阅者
(subscriber)
。事件处理程序是注册到事件的方法,可在任何类或者结构 ......