This has been discussed ad nauseum on IndieGamer and other forums, without much in the way of cast iron solutions, so I'm pretty sure you're going to struggle to do this unless you think creatively. Perhaps not the best suggestion, but an example of what I mean by thinking creatively.
After the graphics mode is set but before the game proper begins, write something to your ini/log file. When the game starts up ( and make sure it's not the first time the game has ever been run by putting another flag in your ini file to account for this ) see if that "the game ran ok last time" flag has been set. If not, pop up a dialog telling the user that the game did not shut down properly last time it was run, and would they like to run in "safe" mode. And revert to software rendering in SDL or whatever your backup is. Also, you'd probably want to tell them where they can go to set it back to DX / OGL if they find that the game is running slowly and want to get out of "safe mode" again.
Or perhaps create and destroy a texture as soon as the graphics mode is set and check that they are valid. If not, same as above.
Or perhaps count the time the game was run for. If it closes down in less than 5 seconds, or if there is no record in the ini file that your game shut down properly ( write something to the ini/debug when the game shuts down ) then it must not have run correctly, and you can offer to run in safe mode or whatever.
Just a thought, because I don't think you're ever gonna find a perfect way of detecting it directly.
After the graphics mode is set but before the game proper begins, write something to your ini/log file. When the game starts up ( and make sure it's not the first time the game has ever been run by putting another flag in your ini file to account for this ) see if that "the game ran ok last time" flag has been set. If not, pop up a dialog telling the user that the game did not shut down properly last time it was run, and would they like to run in "safe" mode. And revert to software rendering in SDL or whatever your backup is. Also, you'd probably want to tell them where they can go to set it back to DX / OGL if they find that the game is running slowly and want to get out of "safe mode" again.
Or perhaps create and destroy a texture as soon as the graphics mode is set and check that they are valid. If not, same as above.
Or perhaps count the time the game was run for. If it closes down in less than 5 seconds, or if there is no record in the ini file that your game shut down properly ( write something to the ini/debug when the game shuts down ) then it must not have run correctly, and you can offer to run in safe mode or whatever.
Just a thought, because I don't think you're ever gonna find a perfect way of detecting it directly.