闁衡偓閹増顥� (0) +1 閻犙嶆嫹 (0) +1 闂婎亷鎷� (0) +1
闁衡偓閹増顥戦柟瀛樺姇婵拷闁哄被鍎冲﹢鍛村绩閹増顥�>>

正在阅读:在VC++中播放WAV文件在VC++中播放WAV文件

2004-04-08 10:11 出处:VChome 作者:佚名 责任编辑:sdq

  首先,你必须手工将WAV文件加入到资源文件.rc 中。

  象这样:wave

  例子:
cool wave c:\projects\sounds\cool.wav
  
  然后,在你需要播放
WAV的地方加入下面的函数:

  
bool playresource(lpstr lpname)
  {
  bool brtn;
  lpstr lpres;
  handle hres;
  hrsrc hresinfo;
  hinstance nl=afxgetinstancehandle();

  /* find the wave resource. */
  hresinfo= findresource(nl,lpname,"wave");
  if(hresinfo == null)
  return false;
  /* load the wave resource. */

  hres = loadresource(nl,hresinfo);
  if (hres == null)
  return false;

  /* lock the wave resource and play it. */
  lpres=(lpstr)lockresource(hres);
  if(lpres==null)
  return false;

  brtn = sndplaysound(lpres, snd_memory | snd_sync);
  if(brtn == null)
  return false;

  /* free the wave resource and return success or failure. */
  freeresource(hres);
  return true;
  }
  
  最后,你就可以使用了。

  playresource("cool");


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
闁归潧顑嗗┃鈧悹浣告健濡拷闁搞儳鍋涢崺灞俱亜閸洖鍔�