以下代码可以编译通过,可是为什么当我把hello.txt用word打开后再运行这个代码弹出的对话框的内容是操作系统的提示“在存取 d:\hello.txt 时发生共享违例。”而不是我自己定义的“Sharing Violation!”呢?
但是当两个“////////????????????????????”之间的部分改为“
catch (CFileException *e) {
switch(e->m_cause) {”之后又可以按我自定义的提示呢?////////////////////////////////Begin////////////////////////////////
CString str = "Hello World!";
CString strPath = "d:\\hello.txt"; try {
CFile file(strPath, CFile::modeCreate |CFile::modeWrite);
file.Write(str,str.GetLength());
file.Close();
}
////////????????????????????
catch (CFileException e) {
switch(e.m_cause) {
////////????????????????????
case CFileException::sharingViolation:
MessageBox("Sharing Violation!");
break;
case CFileException::badPath:
MessageBox("Invalid Path!");
break;
}
}
/////////////////////////////////End//////////////////////////////////
但是当两个“////////????????????????????”之间的部分改为“
catch (CFileException *e) {
switch(e->m_cause) {”之后又可以按我自定义的提示呢?////////////////////////////////Begin////////////////////////////////
CString str = "Hello World!";
CString strPath = "d:\\hello.txt"; try {
CFile file(strPath, CFile::modeCreate |CFile::modeWrite);
file.Write(str,str.GetLength());
file.Close();
}
////////????????????????????
catch (CFileException e) {
switch(e.m_cause) {
////////????????????????????
case CFileException::sharingViolation:
MessageBox("Sharing Violation!");
break;
case CFileException::badPath:
MessageBox("Invalid Path!");
break;
}
}
/////////////////////////////////End//////////////////////////////////
解决方案 »
- 为什么的我写的截图程序总是运行到LocalFree就停了?
- 【HELP】如何改变对话框边框的颜色
- keybd_event键盘模拟函数遇到的问题,代码五行,帮我看下
- 请问哪儿有手机里的小图标下载的?
- 问一个vc的编译问题(Error spawning cl.exe)
- 打造中国最好的输入法
- 请教对话框关闭后,能否使mainframe的OnCreateClient执行??
- 内嵌ie浏览器 截获页面跳转后在自己客户端中打开跳转的url,新浪广告失去焦点
- 【硬盘的重大问题】 我在c盘装的windows98,在装了xp之后,就用删除的方法把c盘的文件删除了 然后就用xp的命令行format,就有下面的情况
- 右键弹出菜单的响应问题
- 如何禁止移动窗口中的工具条?
- 请问各位大侠如何将EXCEL格式的数据转换成ACCESS保存到数据库中啊
catch (CFileException *e)
{
switch(e->m_cause) {
case CFileException::sharingViolation:
MessageBox("Sharing Violation!");
break;
case CFileException::badPath:
MessageBox("Invalid Path!");
break;
}
}