Code that exists in both EXE and DLL - mainly error handling code. * * * Error and Event Log related functions. * * *************************************************************************/
| 1371 | * |
| 1372 | *************************************************************************/ |
| 1373 | static void ReportAPIError(DWORD msgCode, DWORD errCode /*= 0*/) |
| 1374 | { |
| 1375 | if (errCode==0) |
| 1376 | errCode = GetLastError(); |
| 1377 | |
| 1378 | const int bufSize = 512; |
| 1379 | TCHAR buf[bufSize]; |
| 1380 | BOOL bHaveMessage = (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errCode, 0, buf, bufSize, NULL )>0); |
| 1381 | if (!bHaveMessage) |
| 1382 | _tcscpy(buf,TEXT("No error message is available")); |
| 1383 | /* strip trailing cr/lf */ |
| 1384 | int end = _tcslen(buf)-1; |
| 1385 | if (end>1 && (buf[end-1]==L'\n' || buf[end-1]==L'\r')) |
| 1386 | buf[end-1] = L'\0'; |
| 1387 | else |
| 1388 | if (end>0 && (buf[end]==L'\n' || buf[end]==L'\r')) |
| 1389 | buf[end]=L'\0'; |
| 1390 | |
| 1391 | TCHAR cvtBuf[20]; |
| 1392 | wsprintf(cvtBuf, L"%d", errCode); |
| 1393 | LPTSTR lpszStrings[] = {cvtBuf, buf, L'\0'}; |
| 1394 | ReportError(msgCode, (LPCTSTR *)lpszStrings); |
| 1395 | } |
| 1396 | |
| 1397 | static void ReportPythonError(DWORD code) |
| 1398 | { |
no test coverage detected