📄 sound.cs
字号:
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace SmartAnswerCall
{
public class Sound
{
private string m_fileName;
private byte[] m_soundBytes;
public Sound(Stream stream)
{
this.m_soundBytes = new byte[stream.Length];
stream.Read(this.m_soundBytes, 0, (int)stream.Length);
}
public Sound(string fileName)
{
this.m_fileName = fileName;
}
public void Play()
{
if (this.m_fileName != null)
{
WCE_PlaySound(this.m_fileName, IntPtr.Zero, 0x20001);
}
else
{
WCE_PlaySoundBytes(this.m_soundBytes, IntPtr.Zero, 5);
}
}
[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private static extern int WCE_PlaySound(string szSound, IntPtr hMod, int flags);
[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private static extern int WCE_PlaySoundBytes(byte[] szSound, IntPtr hMod, int flags);
private enum Flags
{
SND_ALIAS = 0x10000,
SND_ALIAS_ID = 0x110000,
SND_ASYNC = 1,
SND_FILENAME = 0x20000,
SND_LOOP = 8,
SND_MEMORY = 4,
SND_NODEFAULT = 2,
SND_NOSTOP = 0x10,
SND_NOWAIT = 0x2000,
SND_RESOURCE = 0x40004,
SND_SYNC = 0
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -