关于打开音频文件的有关问题

关于打开音频文件的问题
BYTE *GetData(CString *pString)
{
if(pString == NULL)
return NULL;
HMMIO file1;//定义HMMIO文件句柄;
file1 = mmioOpen((LPTSTR)pString,NULL,MMIO_READWRITE);//以读写模式打开所给的WAVE文件;
if(file1==NULL)
{
::MessageBox(NULL,_T("WAVE文件打开失败!"),_T("haha"),MB_OK);
return NULL;
}......这是一个函数的一部分.

我想在DLG类中调用他打开一个已存在的音频文件..但是总是提示文件打开失败..
void CMy::OnBnClickedButton1()
{

// TODO: 在此添加控件通知处理程序代码;
CString pString;
pString = ("c:\\g2.wav");



  GetData(&pString) ;
}
这是为什么呀?些文件我八用符件带的录音机录的.已存好了.

------解决方案--------------------
那你用GetLastError()获取mmioOpen,看看具体是对应于下面那种情况~~
Return Values

Returns a handle of the opened file. If the file cannot be opened, the return value is NULL. If lpmmioinfo is not NULL, the wErrorRet member of the MMIOINFO structure will contain one of the following error values.

Value Description 
MMIOERR_ACCESSDENIED The file is protected and cannot be opened. 
MMIOERR_INVALIDFILE Another failure condition occurred. This is the default error for an open-file failure. 
MMIOERR_NETWORKERROR The network is not responding to the request to open a remote file. 
MMIOERR_PATHNOTFOUND The directory specification is incorrect. 
MMIOERR_SHARINGVIOLATION The file is being used by another application and is unavailable. 
MMIOERR_TOOMANYOPENFILES The number of files simultaneously open is at a maximum level. The system has run out of available file handles. 

------解决方案--------------------
file1 = mmioOpen((LPTSTR)pString->GetBuffer(0) ,NULL,MMIO_READWRITE);
------解决方案--------------------

问题的原因可能是:

GetData(CString *pString)

这个函数的参数定义为 CString 的指针了。

==========================================

我的解决方法:

mmioOpen 函数定义如下:

C/C++ code

HMMIO mmioOpen(
  LPSTR szFilename,       
  LPMMIOINFO lpmmioinfo,  
  DWORD dwOpenFlags       
);