TRACE用于debug模式下

TRACE用于debug模式下。

MSDN地址:https://msdn.microsoft.com/zh-cn/library/w6xa1ayx(v=vs.80).aspx

Example

TRACE0:

// Example for TRACE0
TRACE0( "Start Dump of MyClass members:" );

// Another example for TRACE0
// This works, but it is easier to use TRACE() or TRACE1()
DWORD dwLastError = ::GetLastError();
CString str;
str.Format("The last error code for this thread is %d\n", dwLastError);
TRACE0( (LPCTSTR) str);

// These are all normal uses of TRACE0()
TRACE0("This message will be output. ");
TRACE0("This text is on the same line.\n");
TRACE0("This text is on the next line.\n");
TRACE1:

// Example for TRACE1
int i = 1;
TRACE1( "Integer = %d\n", i );
// Output: 'Integer = 1'

// Another example for TRACE1
DWORD dwLastError = ::GetLastError();
TRACE1("The last error code for this thread is %d\n", dwLastError);

TRACE2:

// Example for TRACE2
int i = 1;
char sz[] = "one";
TRACE2( "Integer = %d, String = %s\n", i, sz );
// Output: 'Integer = 1, String = one'

// Another example for TRACE2
// Get major and minor version numbers of Windows
DWORD dwVersion = GetVersion();
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

TRACE2("This is Windows version %d.%2.2d.\n", dwWindowsMajorVersion, dwWindowsMinorVersion);

TRACE3:

// Example for TRACE3
// get the display context
HDC hdc = ::GetDC(NULL);

// Get information about the display
int nVertRes = ::GetDeviceCaps(hdc, VERTRES);
int nHorzRes = ::GetDeviceCaps(hdc, HORZRES);
int nDepth = ::GetDeviceCaps(hdc, BITSPIXEL);

// Done with the DC, give it back
::ReleaseDC(hdc);

// Tell the user
TRACE3("Your screen is at %d by %d resolution, with %d bits per pixel\n",
   nHorzRes, nVertRes, nDepth);







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值