Solved

simple exception handling

Posted on 2004-04-06
12
187 Views
Last Modified: 2013-11-20
hello experts,

i'm very new on exception handling on a PDA, using embedded visual c++ 3.0, I would like to only catch CMemoryExceptions.
how can i do this?
i know it is with
__try{
     code where exception can get thrown
}
__except ... but here i'm stuck. How can i only catch CMemoreException?

thx,
0
Comment
Question by:lolliebollie
  • 4
  • 3
  • 2
12 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 10765861
try
{
  blah blah blah;
}
catch (CMemoryExcpeiton* exception)
{
  blah blah blah;
}

Should do the trick.  A catch block only catches exceptions of the type it specifies (or objects derived from that object).

Hope this helps.
0
 

Author Comment

by:lolliebollie
ID: 10765930
in visual c++ this would work, but it doesn't in embedded visual c++.
embedded visual c++ doesn't suppport  this way of exception handling.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10765981
If you must use the try...except clause, you will need to write a filter routine to handle the event.  The try...except only catches terminating events, and under C++ the catch is much more flexible, but there could be reasons why you need the try...except block.

In that case, check out the example at the bottom of this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_langref_try_except_statement.asp

Hope this helps.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10766007
Oh and a list of teh exceptions you can filter on is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/minidump_exception_str.asp

Sorry that the catch doesn't work in embedded C++.  Odd that.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Accepted Solution

by:
lakshman_ce earned 50 total points
ID: 10766028
I think KurtVon's method should work. Embedded Visual C++ supports both C++ Exception handling(KurtVon's code) and structured exception handling (your code)
Plz refer to this for details
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/elgrfexceptionhandling.asp
and here is the link for the sample code showing C++ exception handling in the embedded VC++ MSDN reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/ellrftrycmacatchcmaandthrowstatements.asp

-Lakshman
0
 

Author Comment

by:lolliebollie
ID: 10766273
thx for the fast replys,

i'll give it a try

and for the try and catch i found that windows CE doesn't support this, and if i try i get the warning
"warning C4531: C++ exception handling not available on Windows CE. Use Structured Exception Handling"

i'll get back to you guys, thx :)
0
 

Author Comment

by:lolliebollie
ID: 10766480
and Lakshman you"re right, in some places u find that evc supports structured exception handling and some other places you find that it doesn't, and also if you try to compile u see a message they don't (^^)

i find it strange
0
 

Author Comment

by:lolliebollie
ID: 10766495
evc 3.0 doesn't support, but evc 4.0 does :)
to bad i have to use 3.0
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10766510
Upgrade to evc 4.0 :-)

-Lakshman
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Unix / Linux grid computing 5 144
My project did see openJDK that I installed. What could be the problem 7 121
Thin secure Windows 10 5 73
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now