作者Pondingla (= =+)
看板C_Sharp
标题[问题]Windows Mobile6.0上 wav无法拨放
时间Fri Nov 4 14:58:29 2011
大家好, 目前正在6.0手机上开发专案 .NET Framework 为2.0
程式是写成当讯息传送到手机时会有提醒音效
爬了许多文跟看了资料後, 知道要使用CoreDll.dll档
因无法在方案总管直接加入参考,故使用DllImport("CoreDll.dll")的方法
但还是失败....希望板上的前辈可帮忙看看是哪里有问题 > <
程式码如下
public const UInt32 SND_SYNC = 0x00000000;
public const UInt32 SND_FILENAME = 0x00020000;
public const UInt32 SND_ASYNC = 0x00000001;
public const UInt32 SND_RESOURCE = 0x00040004;
[DllImport("CoreDll.dll",
CallingConvention = CallingConvention.Winapi,
CharSet = CharSet.Unicode,
EntryPoint = "PlaySound",
PreserveSig = true,
SetLastError = false)]
public extern static bool PlaySound(String pszSound, IntPtr hmod,
UInt32 fdwSound);
string a="Program Files\\SoundSample\\DOG04.WAV";
//string a = "DOG04.WAV";
private void button1_Click(object sender, EventArgs e)
{
//前面为判断有无讯息的判断式,之後就call PlaySound
PlaySound(a, IntPtr.Zero, SND_ASYNC | SND_FILENAME);
}
程式可在手机上执行, 讯息也传成功, 但就是没有音效
是否跟路径有关? 也试过直接读取档名(使用SND_RESOURCE) 但都不成功.....
谢谢指教!!!! 麻烦了!!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.108.205.57
1F:推 knifehandz:有试过除错追踪看看程式怎麽跑吗,在PlaySound里设断点 11/06 04:33
2F:→ Pondingla:有在Playsound後面加上messagebox,程式也可执行到那边 11/07 12:17
3F:→ Pondingla:还是不知道哪边出错.... 11/07 12:18