SysTools Logo SysTools


C, WinAPI: OutputDebugString() with printf() formatted output


// Put a formatted string to the debug output.
// References and documentation links for this code:
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms647551.aspx
// To list debug strings use DebugView by SysInternals:
// https://technet.microsoft.com/en-us/sysinternals/bb896647
void WINAPIV DebugOut(const TCHAR *fmt, ...) {
TCHAR s[1025];
va_list args;
  ZeroMemory(s, 1025 * sizeof(s[0]));
  va_start(args, fmt);
  wvsprintf(s, fmt, args);
  va_end(args);
  s[1024] = 0;
  OutputDebugString(s);
}

// example of usage:
// DebugOut(TEXT("Hello from %s (PID = %d)"), TEXT("me!"), GetCurrentProcessId());

2015.04.15


[ Код ]