0

I am writing a C++ application, and I want to add a timestamp to OutputDebugString(). I already know that if I watch the application using DebugView, it automatically show timestamps. But for a particular reason I want to add TimeStamps to any string I pass to OutputDebugString().

What would some sample code be?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Are you asking how to change existing system function so that when you call it with "some string" actual result becomes "[time_stamp] some string"? – Dialecticus Sep 27 '11 at 20:40

1 Answers1

1

You could use QueryPerformanceCounter and QueryPerformanceFrequency to get a high-resolution timestamp. If you set a variable to the value returned by QueryPerformanceCounter before your program really starts executing, you can achieve the same effect as debug view by subtracting this initial value from the current performance counter value when printing to a debug string. GetTickCount is another API you can use, although the resolution isn't as good.

James Johnston
  • 9,264
  • 9
  • 48
  • 76