Solved

Monitoring an application with C++

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 clear a vector as well as how to detect empty vectors in C++.

746 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

12 Experts available now in Live!

Get 1:1 Help Now