今天给大家分享的是由图老师小编精心为您推荐的在VC++中播放WAV文件,喜欢的朋友可以分享一下,也算是给小编一份支持,大家都不容易啊!
【 tulaoshi.com - 编程语言 】
首先,你必须手工将WAV文件加入到资源文件.rc 中。
象这样:wave
  例子:cool wave c:projectssoundscool.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");
来源:http://www.tulaoshi.com/n/20160219/1606995.html
看过《在VC++中播放WAV文件》的人还看了以下文章 更多>>