"Bill Gates" <BillGates@microsoft.com> wrote in message
news:uc8dIJHQHHA.3544@TK2MSFTNGP03.phx.gbl
How to catch system exception on windows?
for example,
try
{
int *pInt = NULL;
*pInt = 0;// throw some kind of exception
}
catch ( .../*catch what here?*/ )
{
}
Thanks!
int main()
{
__try
{
int *pInt = NULL;
*pInt = 0;// throw some kind of exception
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
DWORD dw = GetExceptionCode();
switch(dw)
{
case EXCEPTION_ACCESS_VIOLATION:
cout << "access violation\n";
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
cout << "int divide by zero\n";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
cout << "floating point divide by zero\n";
break;
// other cases
}
}
return 0;
}
--
John Carson