__try
{
CString str="afd";
MessageBox(str.GetBuffer(0));
}
__finally
{
MessageBox("finally");
}
出现以下错误提示
warning C4509: nonstandard extension used: 'OnButton1' uses SEH and 'str' has destructor;Cannot use __try in functions that require object unwinding
{
CString str="afd";
MessageBox(str.GetBuffer(0));
}
__finally
{
MessageBox("finally");
}
出现以下错误提示
warning C4509: nonstandard extension used: 'OnButton1' uses SEH and 'str' has destructor;Cannot use __try in functions that require object unwinding
解决方案 »
- 关于屏蔽鼠标消息问题~~~求助各位!
- 关于线程问题!
- 有关农历控件的数据类型的问题
- CDHtmlDialog 的问题(js关闭ie的问题)
- 如何使多文档中同一模板每次只能打开一次?
- 为什么我装Visual C++ Assistant后,vc打开以前的程序老是有问题?
- 如何得到文件所占用的空间?
- 高手请进~~关于release 编译后HOOK API 失败的原因!!
- 【MFC】用位图填充一个窗口,并随着窗口大小的改变而改变,发现位图有时候会不显示
- 急救-----给分100
- codeproject里有个statusbar扩展类,可以对每个panel设置不同的字体颜色.但我想动态地改变其文字类容,改怎么办?
- 我也能找到工作?散分!
SEH不允许在内部定义有析构函数的变量
__try
{
MessageBox(str.GetBuffer(0));
}
__finally
{
MessageBox("finally");
}同样错。
strcpy( sz, "afd" );__try
{
MessageBox(sz);}
__finally
{
MessageBox("finally");
}
__try
{
MessageBox(str->GetBuffer(0));
}
__finally
{
MessageBox("finally");
delete str;
}错误提示:Cannot use __try in functions that require object unwinding。Microsoft的try真是垃圾,远比不上delphi的try.
:) 这就是你无知了. __try 和 try 是不同的东西.__try 叫SEH, 结构化异常. 是捕捉系统异常用的.
------------------------------
Microsoft C++ supports two kinds of exception handling: C++ exception handling (try, throw, catch)
Structured exception handling (__try/__except, __try/__finally)
Although structured exception handling works with C and C++ source files, it is not specifically designed for C++. For C++ programs, you should use C++ exception handling.
结构化异常不能出现在带有析构函数的C++程序里.例如:
class CA
{
public:
CA()
{
__try
{
}
__finally
{
}
} //~CA();
};
OK!----------------
class CA
{
public:
CA()
{
__try
{
}
__finally
{
}
} ~CA();
};
NOT OK!!!
根据你的用途分析, 你应该用 try__try是用来捕捉 EnterCriticalSection 这种系统 API 所产生的异常的。delphi的try可以吗?