mmioOpen API有问题 [英] A problem with mmioOpen API

查看:157
本文介绍了mmioOpen API有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个播放.wav文件的音频播放器.我编写了一个ReadWaveFile(CString szFilename)函数,用于将文件的wave数据读取到WAVEHDR结构中.在此功能

I am trying to make an audio player that plays .wav files. I wrote a function ReadWaveFile(CString szFilename) for reading the wave data of the file into the WAVEHDR structure. In this function

<pre>
BOOL CWavePlay::ReadWaveFile(CString szFilename)
{
	hmmio = mmioOpen((LPTSTR)&szFilename,NULL,MMIO_READ);
	ASSERT(hmmio);		//error here: hmmio=0x00000000
	if(hmmio==0)
		return FALSE;
        ....
}


每当我将文件路径传递给此函数以打开指定的文件时,mmioOpen始终返回0.而且令我感到困惑的是,当我在mmioOpen API中显式传递文件路径时,代码可以工作;即返回有效的句柄.


mmioOpen is always returning 0 whenever I pass a filepath to this function for opening the specified file. And what baffles me is when i pass the filepath explicitly in mmioOpen API the code works; i.e., a valid handle is returned.
can some body explain why is this happening??

推荐答案

尝试一下-hmmio = mmioOpen((LPTSTR)szFilename,NULL,MMIO_READ);
您还可以将PlaySound API与SND_FILENAME标志一起使用.
Try this - hmmio = mmioOpen((LPTSTR)szFilename,NULL,MMIO_READ);
You could also use the PlaySound API with the SND_FILENAME flag.


解决方案是:
the solution is:
<pre>hmmio = mmioOpen((LPTSTR)(LPCTSTR)szFilename,NULL,MMIO_READ);


这篇关于mmioOpen API有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆