#ifndef __MYDBG_HEADER_FILE_
#define __MYDBG_HEADER_FILE_
#define __DBG_RELEASE
#ifdef __DBG_RELEASE
void DbgPrintfA(LPCSTR lpFmt,...);
void DbgPrintfW(LPCWSTR lpFmt,...);
void DbgDumpBuf(const void* pBuf,int nSize);
#pragma message("Build with DbgPrintf information.Remove __DBG_RELEASE to avoid this message")
#else
#define DbgPrintfA
#define DbgPrintfW
#define DbgDumpBuf
#endif
#endif
==========
#include "stdafx.h"
#include
#include "MyDbg.h"
#define __DBG_RELEASE
#ifdef __DBG_RELEASE
void DbgPrintfA(LPCSTR lpFmt,...)
{
char szBuf[1024];
memset(szBuf,0,1024);
va_list argList;
va_start(argList, lpFmt);
wvsprintfA(szBuf,lpFmt, argList);
va_end(argList);
OutputDebugStringA(szBuf);
}
void DbgPrintfW(LPCWSTR lpFmt,...)
{
WCHAR szBuf[1024];
memset(szBuf,0,1024);
va_list argList;
va_start(argList, lpFmt);
wvsprintfW(szBuf,lpFmt, argList);
va_end(argList);
OutputDebugStringW(szBuf);
}
void DbgDumpBuf(const void* pData,int nSize)
{
PBYTE pBuf = (PBYTE)pData;
char szMsg[512];
memset(szMsg,0,512);
char* p = szMsg;
for(int i=0;i
wsprintfA(p,"%02X ",pBuf[i]);
p+=3;
if((i!=0)&&(i%7==0))
{
DbgPrintfA(szMsg);
memset(szMsg,0,512);
p = szMsg;
}
}
}
#endif