首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC CFILE Seek错误处理无效怎么处理

2012-05-07 
MFC CFILE Seek异常处理无效怎么办最近在做播放器,遇到一个麻烦的问题。用播放器打开一个音乐文件,比如A.mp

MFC CFILE Seek异常处理无效怎么办
最近在做播放器,遇到一个麻烦的问题。
用播放器打开一个音乐文件,比如A.mp3,此时这个文件被占用。
然后再用我的播放器打开列表,因为列表要一个一个读取文件信息,
读取到这个文件时,就会出现错误提示框。
说是找不到A.mp3,调试的时候,会发现
file.Seek(-128,CFile::end);
这里出错了,用try{}catch(CFileException *e){;}
也无效,还是弹出错误提示框,列表后面的文件也不会被读取,被中断了。
请问怎么处理。分不多,还请高手救命。

[解决办法]
file.Open((LPCTSTR)path,CFile::modeRead);
-->
CFile file((LPCTSTR)path,CFile::modeRead);

[解决办法]
While the CFile constructor will throw an exception in an error condition, Open will return FALSE for error conditions. Open can still initialize a CFileException object to describe the error, however. If you don't supply the pError parameter, or if you pass NULL for pError, Open will return FALSE and not throw a CFileException. If you pass a pointer to an existing CFileException, and Open encounters an error, the function will fill it with information describing that error. In neither case will Open throw an exception. 

看这个

热点排行