|
|
|
@@ -18,6 +18,39 @@ |
|
|
|
|
|
|
|
typedef void (*TTL_Generator_Function)(const char* basename); |
|
|
|
|
|
|
|
void ErrorExit(LPTSTR lpszFunction) |
|
|
|
{ |
|
|
|
// Retrieve the system error message for the last-error code |
|
|
|
|
|
|
|
LPVOID lpMsgBuf; |
|
|
|
LPVOID lpDisplayBuf; |
|
|
|
DWORD dw = GetLastError(); |
|
|
|
|
|
|
|
FormatMessage( |
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM | |
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS, |
|
|
|
NULL, |
|
|
|
dw, |
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
|
|
(LPTSTR) &lpMsgBuf, |
|
|
|
0, NULL ); |
|
|
|
|
|
|
|
// Display the error message and exit the process |
|
|
|
|
|
|
|
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, |
|
|
|
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)); |
|
|
|
sprintf((LPTSTR)lpDisplayBuf, |
|
|
|
TEXT("%s failed with error %d: %s"), |
|
|
|
lpszFunction, dw, lpMsgBuf); |
|
|
|
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK); |
|
|
|
|
|
|
|
LocalFree(lpMsgBuf); |
|
|
|
LocalFree(lpDisplayBuf); |
|
|
|
ExitProcess(dw); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
int main(int argc, char* argv[]) |
|
|
|
{ |
|
|
|
if (argc != 2) |
|
|
|
|