VS2005 API调用声音函数 无效?

我在深圳搬砖-Justin 2009-08-29 09:25:24

using System.Runtime.InteropServices;

[DllImport("winmm.dll")]
public static extern bool PlaySound(string pszSound, int hmod, int fdwSound);
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;


private void GetSound(object sender, EventArgs e)
{
PlaySound("folder.wav", 0, SND_ASYNC|SND_FILENAME);

}


代码如上,为什么在VS2003里面可以 但是在05里面不行呢/?
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChrisAK 2009-08-30
  • 打赏
  • 举报
回复
代码看起来没问题.
检查下文件路径啥的吧.
最好敲绝对路径.
wuyq11 2009-08-30
  • 打赏
  • 举报
回复
代码没问题
wuyq11 2009-08-30
  • 打赏
  • 举报
回复
vs2005里可直接使用SoundPlayer播放
SoundPlayer player= new SoundPlayer();
player.SoundLocation = "";
player.Play();

  • 打赏
  • 举报
回复
代码应该没错 但是不知道为什么这样写 不会有声音?
  • 打赏
  • 举报
回复
谢谢 ChrisAK的 提醒 声音文件应该放在 bin文件夹下面的
dylike 2009-08-29
  • 打赏
  • 举报
回复
My.Computer.Audio.Play("123.wav")
starts_2000 2009-08-29
  • 打赏
  • 举报
回复
System.Media.SoundPlayer

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧