【发布时间】:2015-03-09 21:46:49
【问题描述】:
在 Windows 7 机器上使用以下代码调用 OutputDebugString 时,我只看到“????”在DebugView的打印栏中。我认为这可能是与编码相关的问题,但不确定是否有人以前见过。这是我用来调用 OutputDebugString 的代码。
void dbgprint(char *format, ...)
{
static DWORD pid=0;
va_list vl;
char dbgbuf1[2048],
dbgbuf2[2048];
// Prepend the process ID to the message
if ( 0 == pid )
{
pid = GetCurrentProcessId();
}
EnterCriticalSection(&gDebugCritSec);
va_start(vl, format);
wvsprintf(dbgbuf1, format, vl);
wsprintf(dbgbuf2, "%lu: %s\r\n", pid, dbgbuf1);
va_end(vl);
OutputDebugString(dbgbuf2);
LeaveCriticalSection(&gDebugCritSec);
}
提前感谢您对此问题的任何见解。
【问题讨论】: