#ifndef ERRORMESSAGES_H_ #define ERRORMESSAGES_H_ #ifdef __cplusplus #define EXPORT extern "C" void WINAPI #else #define EXPORT void WINAPI #endif /* Function: ErrorInfo Description: Calls GetLastError() and formats the result into a human readable string which it then displays in a message box The message box has the MB_ICONINFORMATION style set Parameters: None */ EXPORT ErrorInfoA(void); EXPORT ErrorInfoW(void); /* Function: ErrorMessageA/W Description: Takes the input string and displays it in a message box with a caption of "Application Error". The message box has the MB_ICONERROR style set Parameters: LPC(W)STR or string literal - The message to be displayed */ EXPORT ErrorMessageA(LPCSTR); EXPORT ErrorMessageW(LPCWSTR); /* Function: HRErrorInfo Description: The HRESULT equivalent of ErrorInfo(). Displays the textual equivalent of a failed HRESULT in a message box. The message box has the MB_ICONERROR style set Parameters: HRESULT - the value to be converted to its string equivalent Notes: Some HRESULT's don't have an associated string and as such, this function may show a blank message box The return values from WSAGetLastError can be casted to HRESULT and passed into this function to get textual last error messages */ EXPORT HRErrorInfoA(HRESULT); EXPORT HRErrorInfoW(HRESULT); /* Function: DebugPrintA/W Parameters: LPC(W)STR - A printf-style string with a maximum of 2 format specifiers (%s, %i, %x, etc) LPVOID - The first argument to insert into the string LPVOID - If only 1 format specifier is specified in the string then this parameter can be set to NULL. Otherwise, it's the second argument in the string Note: After the arguments have been substituted into the string, only the first 999 characters will appear in the message box. Anything bigger will be truncated at 999. */ EXPORT DebugPrintA(LPCSTR, LPCVOID, LPCVOID); EXPORT DebugPrintW(LPCWSTR, LPCVOID, LPCVOID); #if defined(ERRORM_DEBUG_ONLY) && (!defined(DEBUG) && !defined (_DEBUG)) /* If we only want to use the ErrorMessages.h functions in DEBUG builds but were not in debug mode then define the functions as nothing */ #define ErrorMessage #define DebugPrint #else /* ERRORM_DEBUG_ONLY isn't defined or DEBUG and/or _DEBUG is defined */ #ifdef UNICODE #define ErrorMessage ErrorMessageW #define DebugPrint DebugPrintW #define HRErrorInfo HRErrorInfoW #define ErrorInfo ErrorInfoW #else #define ErrorMessage ErrorMessageA #define DebugPrint DebugPrintA #define HRErrorInfo HRErrorInfoA #define ErrorInfo ErrorInfoA #endif #endif /* ERRORM_DEBUG_ONLY */ #endif /* ERRORMESSAGES_H_ */