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) ;
}
这是为什么呀?些文件我八用符件带的录音机录的.已存好了.

解决方案 »

  1.   

    那你用GetLastError()获取mmioOpen,看看具体是对应于下面那种情况~~
    Return ValuesReturns 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. 
      

  2.   

    file1   =   mmioOpen((LPTSTR)pString->GetBuffer(0) ,NULL,MMIO_READWRITE);
      

  3.   


    问题的原因可能是:GetData(CString   *pString)这个函数的参数定义为 CString 的指针了。==========================================我的解决方法:mmioOpen 函数定义如下:
    HMMIO mmioOpen(
      LPSTR szFilename,       
      LPMMIOINFO lpmmioinfo,  
      DWORD dwOpenFlags       
    );所以定义函数如下:GetData( LPSTR szFilename )
    {
      mmioOpen( szFilename , NULL ...调用时,改为如下:CString pString("c:\\g2.wav");
    GetData( pString.GetBuffer(0) );
      

  4.   

    tccqs的做法对了.zado那么改编译时出现pp(162) : error C2664: 'GetData' : cannot convert parameter 1 from 'wchar_t *' to 'CString *'
      

  5.   

    没zado的做法也对不过GetData(   LPSTR   szFilename   ) ->GetData(   LPWSTR   szFilename   )
    我用的2005谢谢大家..