Solved

Monitoring an application with C++

Posted on 2004-09-21
3
260 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
  • 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

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

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

911 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

21 Experts available now in Live!

Get 1:1 Help Now