Archive

Archive for July, 2012

GetLasterror and OutputDebugString

July 25th, 2012 No comments

How to capture the output of GetLastError using OutputDebugString ?  Because GLE returns a DWORD, OutputDebugString doesn’t seem to like the input.

Put this on next line of the function that is returning the value: -

=============================================
DWORD dwErr = GetLastError();
char Buffer[MAX_PATH+1] = {0};
sprintf_s(Buffer,  MAX_PATH, “Last Err 0x%x\n”, dwErr);
OutputDebugStringA(Buffer);
=============================================

if any other function calls between then buffer holding info will be lost, so you may not get the correct value: – Below is one the example related ScardEstablishedContext()… Read more…

Trace Macro

July 25th, 2012 No comments

wow, so simple…I am writing some tool and was looking for a way to enable tracing, suggested this Macro (added trace to file also)…

static HANDLE  hOut=0;

void LogTrace( LPSTR pFormat, … )
{
char Buffer[MAX_BUFFER_SIZE+1] = {0};
va_list arg_marker;
va_start(arg_marker, pFormat );
DWORD dwBytesWritten=0; //added
wvsprintfA(Buffer, pFormat, arg_marker);
strcat_s(Buffer, _countof(Buffer),”\n”);
va_end(arg_marker); //added Read more…