读书人

c# 传媒应用声音的应用

发布时间: 2012-08-21 13:00:21 作者: rapoo

c# 媒体应用,声音的应用
调用 声音 api

useing System.Runtime.InteropServices;


[DllImport("CoreDll.DLL", EntryPoint = "Play" SetLastError=true]
private static extern int PlaySound(string szSound, IntPtr hMod, int flags);

DllImport() 呼叫的 dll名。
EntryPoint
SetLastError 设置 是否 保存异常。

调用 wav声音

[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private extern static int WavPlay(string szSound, IntPtr hMod, int flags);

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
}

读书人网 >C#

热点推荐