From: Michelle on 13 Aug 2010 17:45 I am writing a C program that uses a file to capture the Microsoft CRT assertions. The related code is like below: ===================================================== invalid_parameter_handler oldHandler, newHandler; #if defined(DEBUG) HANDLE hLogFile; hLogFile = CreateFile(L"c:\\assertlog.txt", GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); newHandler = invalidParamHandler; oldHandler = _set_invalid_parameter_handler(newHandler); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, hLogFile); #endif ===================================================== The above code works when I run my program as a console application. However when I run my program as a Windows service then nothing is captured in the c:\assertlog.txt even when an assertion should happen. Does anyone know what changes should be made for a Windows service to redirect the CRT assertions to a text file? Your response will be very appreciated!
|
Pages: 1 Prev: EH_UNWINDING without non-unwinding call first? |