by Digby » Sep 8, 2001 @ 11:42pm
This might make it easier for you than sending someone multiple .exes with exit(0) sprinkled throughout your initialization routines.<br><br>Inside WinMain(), bracket all your code with __try{}, then add an exception handler. Add a global DWORD variable to your app and init to 0. At the beginning of each of your functions increment the counter by 1. In the exception handler, either write the value to a log file, or put up a message box and display the value. The person running the app and getting the exception needs to give you this value.<br><br>Once you have the value, set a conditional breakpoint on the value of the counter equal to whatever it was when it crashed. Run your app and it should break in the function that caused the error. If your functions contain a lot of code, you can add more calls to bump up the counter variable and ask the person to run again.<br><br>Code with exception handler looks like so:<br><br>DWORD g_dwDbgCnt = 0L;<br><br><br>INT WINAPI WinMain (...)<br>{<br>__try<br>{<br> // all your code in WinMain here<br>}<br>__except (EXCEPTION_EXECUTE_HANDLER)<br>{<br> // save counter value here<br> MessageBox(...)<br><br> // exit the app<br> return 0;<br>}<br> return 0;<br>}<br><br><br>I've done things like this before when I couldn't get a call stack and was able to narrow down where the problem was. What I did was actually write a _penter() routine and compile with /Gh so that the compiler generated a call to _penter() at the entry to every function. This kept me from having to manually add the code to increment the counter variable, and was easier to remove once I found the problem.<br><br>Good luck!<br><br>