开发者

How to add a timestamp to OutputDebugString()?

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 fo开发者_StackOverflow社区r a particular reason I want to add TimeStamps to any string I pass to OutputDebugString().

What would some sample code be?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜