新版格式化输出调试信息

void __cdecl _Dbgf(const TCHAR *format, ...)
{
	va_list vl;
	LONG nCount;
	TCHAR *lpBuffer;

	va_start(vl, format);
	nCount = _vsctprintf(format, vl) + 3;
	lpBuffer = (TCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCount * sizeof(TCHAR));
	_vsntprintf_s(lpBuffer, nCount, _TRUNCATE, format, vl);
	lstrcat(lpBuffer, TEXT("\r\n"));
	OutputDebugString(lpBuffer);
	HeapFree(GetProcessHeap(), 0, lpBuffer);
	va_end(vl);
}

你可能感兴趣的:(新版格式化输出调试信息)