Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top