From 8c4603c73675958efc960fbd4bb599a2909d106a Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 16 Jan 2023 14:52:43 +0100 Subject: Source codes --- Tools/compareTraces/stdafx.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Tools/compareTraces/stdafx.cpp (limited to 'Tools/compareTraces/stdafx.cpp') diff --git a/Tools/compareTraces/stdafx.cpp b/Tools/compareTraces/stdafx.cpp new file mode 100644 index 0000000..5c7f6c9 --- /dev/null +++ b/Tools/compareTraces/stdafx.cpp @@ -0,0 +1,30 @@ +#include "stdafx.h" + +namespace +{ + wchar_t* formatMessage( HRESULT hr ) + { + wchar_t* err; + if( FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + hr, + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + (LPTSTR)&err, + 0, + NULL ) ) + return err; + return nullptr; + } +} + +void printError( HRESULT hr ) +{ + const wchar_t* err = formatMessage( hr ); + if( nullptr != err ) + { + fwprintf( stderr, L"%s\n", err ); + LocalFree( (HLOCAL)err ); + } + else + fprintf( stderr, "Error code %i (0x%08X)\n", hr, hr ); +} \ No newline at end of file -- cgit v1.2.3