If my program encounters a system error, how to prevent the system error message from being displayed?
Printable View
If my program encounters a system error, how to prevent the system error message from being displayed?
Use SetErrorMode(...) look it up on msdn.microsoft.com for the flags you may or may not want to set.
you can use SEH __try{
}__except(EXCEPTION_CONTINUE_EXECUTION ){} for c code
or you can use c++ exception handling try{
}catch(...){} for c++ code
for egsample if u try the following code, you'll get a gpf
long* p = 0;
*p =10;
but if u try this
__try{
long* p = 0;
*p =10;
}__except(EXCEPTION_CONTINUE_EXECUTION ){
}
or this
try{
long* p = 0;
*p =10;
}catch(...){
}
the hard exception will be trapped and control will go to the __except or catch(...) block
hope this helps
Better to use C++ exception handling and install a set_se_translator(...)Quote:
Originally posted by raghupathys
you can use SEH __try{
}__except(EXCEPTION_CONTINUE_EXECUTION ){} for c code
or you can use c++ exception handling try{
}catch(...){} for c++ code
for egsample if u try the following code, you'll get a gpf
long* p = 0;
*p =10;
but if u try this
__try{
long* p = 0;
*p =10;
}__except(EXCEPTION_CONTINUE_EXECUTION ){
}
or this
try{
long* p = 0;
*p =10;
}catch(...){
}
the hard exception will be trapped and control will go to the __except or catch(...) block
hope this helps