开发者

How to add a timestamp to OutputDebugString()?

开发者 https://www.devze.com 2023-04-09 01:15 出处:网络
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开发者_Sta

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

精彩评论

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

关注公众号