-
Self Terminate an App
Alright, my Dx7 engine checks for and inits certain interfaces in its constructor.
If I cannot create a certain one it shows a messagebox saying it cannot find it.
I want at that point to terminate the application, a proper terminate, all memory gone and such. So how do I terminate an app within a class's constructor?
I will know nothing, no hwnd, no thread, no hinstance.
-
I guess you have to send the info to the constructor, or you have to write a try catch block around the lines that makes the object.
-
Hmmmm...Well...
Would that work in the case of DX?
If it fails in initializing it only returns a simple value saying it failed, does it flag an error on the system to?
try
{
//code
}
i aint sure how to work a try catch...can u give example
-
Not sure if I am getting you. Making the DX object is the first thing that you do. So there isn't actualy anything to clean up. So something like this is pretty normal to do.
Code:
CMyD3DApplication d3dApp;
if( FAILED( d3dApp.Create( hInst ) ) )
return 0;
-
yah, except the constructor cannot return anything.
When my dx7 engine constructs I want it to interface to DD, D3D...if it fails I want the program to exit and let the user know wut happened.
I guess the easy resolve would be to take the init out of the constructor.
-
So create your special object on the heap:
Code:
boost::shared_ptr<MyDXWrapper> dx;
try {
dx.reset(new MyDXWrapper);
} catch(const std::exception &e) {
// Init failed
return 1;
}