Solved

Monitoring an application with C++

Posted on 2004-09-21
3
267 Views
Last Modified: 2008-01-16
Hi,

I want to monitor an application written in MFC which crash some times, what I want to do is, get rid of Microsoft popup message and restart the program in monitor program, it's important the program is restart again automatically, cuz there is no operator around to restart the application, I tried to override ProcessWndProcException in the application but still get the popup, the application is a consol application , then I used __try __except in main , but still get the popup, I don't know when in code it crashes and don't want to go in all my code and add try and catch, I was looking at CreateProcess as well, but still it doesn't help to get rid of popup. So I am looking for a solution for monitoring and spawn my process, and if it crashes restart it again.

regards
/m
0
Comment
Question by:Marjaneh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 12113775
>>what I want to do is, get rid of Microsoft popup message and restart the program in monitor
>>program

IF you have the code to the MFC app, add

SetErrorMode(SEM_NOGPFAULTERRORBOX);

so the message box will not come up. Then, start it from a batch file like

@echo off
:respawn
start /WAIT c:\path\theapp.exe
goto respawn
0
 

Author Comment

by:Marjaneh
ID: 12120700
Hi jkr,

Thanks for your comment, it doesn't work when crashes happend in a thread I guess, I tried to in our lab and I still get the popup, but when I simulate a null pointer exception in main in my computer it doesn't come up. I don't want to use batch file to monitor I want to have some statistic as well when it crashes, so I put that in both monitor program and in the main of MFC application.
I will investigate more and get back.

/BR
0
 

Author Comment

by:Marjaneh
ID: 12317021
Hi jkr,
I added this command to the command you sugested and now it works, I think this one do the job  but because no one hase answered me so I will give you the points.
thank you.

you can use: SetUnhandledExceptionFilter( __XceptFilter);

which

LONG WINAPI __XceptFilter (EXCEPTION_POINTER *pExp)
{
......
return EXCPTION_EXECUTE_HANDLER; // or some other code
}
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

732 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