SqlPipe.cpp
// Get human-readable message given a HRESULT
Get human-readable message given a HRESULT
Get human - readable message given a HRESULT
_bstr_t errorMessage(DWORD messageId)
{
	LPTSTR szMessage;
	if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, messageId, 0, (LPTSTR)&szMessage, 0, NULL))
	{
		szMessage = (LPTSTR)LocalAlloc(LPTR, 50 * sizeof(TCHAR));
		_snwprintf(szMessage, 50 * sizeof(TCHAR), L"Unknown error 0x%x.\n", messageId);		
	}
	_bstr_t retval = szMessage;
	LocalFree(szMessage);
	return retval;
}
_bstr_t errorMessage ( DWORD messageId ) { LPTSTR szMessage ; if ( ! FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM , NULL , messageId , 0 , ( LPTSTR ) & szMessage , 0 , NULL ) ) { szMessage = ( LPTSTR ) LocalAlloc ( LPTR , 50 * sizeof ( TCHAR ) ) ; _snwprintf ( szMessage , 50 * sizeof ( TCHAR ) , L" \n " , messageId ) ; } _bstr_t retval = szMessage ; LocalFree ( szMessage ) ; return retval ; }
Get human-readable message given a HRESULT
Get human - readable message given a HRESULT