MyHandleError

The MyHandleError function is an example of a tool function used to print an error message and exit the calling program. The examples for several CryptoAPI functions in Cryptography Reference and the more extended examples in Using Cryptography implement this function. Real applications may require more complex error handling capability.


#include <stdio.h>
#include <tchar.h>
#include <windows.h>

void MyHandleError(LPTSTR psz)
{
    _ftprintf(stderr, TEXT("An error occurred in the program. \n"));
    _ftprintf(stderr, TEXT("%s\n"), psz);
    _ftprintf(stderr, TEXT("Error number %x.\n"), GetLastError());
    _ftprintf(stderr, TEXT("Program terminating. \n"));
    exit(1);
} // End of MyHandleError



 

 

Show: