win32 sdk 编程,该怎么解决
win32 sdk 编程
在图形界面编程中,在调试的时候经常需要用标准输入输出,将结果输到控制台,在vs中怎么实现呢?或者是有其他方式
------解决思路----------------------
一般做win程序不会需要控制台输入的,必须的话可以从文件读取
输出runtime信息,你也可以输出到文件里面,如果有个日志库自然更为方便
如果只是debug,你可以试试
#include <debugapi.h>里面的函数DebugOutputString,这个函数的输出会被VS的输出栏捕获
可以用_Debug宏把代码限定为非Release
一个参考
------解决思路----------------------
楼主为什么不看看Win32 sdk自带的例子代码呢?
Debugging Functions
The following functions are used with debugging.
ContinueDebugEvent
DebugActiveProcess
DebugBreak
FatalExit
FlushInstructionCache
GetThreadContext
GetThreadSelectorEntry
IsDebuggerPresent
OutputDebugString
ReadProcessMemory
ReadProcessMemoryVlm
SetDebugErrorLevel
SetThreadContext
WaitForDebugEvent
WriteProcessMemory
WriteProcessMemoryVlm
在图形界面编程中,在调试的时候经常需要用标准输入输出,将结果输到控制台,在vs中怎么实现呢?或者是有其他方式
------解决思路----------------------
一般做win程序不会需要控制台输入的,必须的话可以从文件读取
输出runtime信息,你也可以输出到文件里面,如果有个日志库自然更为方便
如果只是debug,你可以试试
#include <debugapi.h>里面的函数DebugOutputString,这个函数的输出会被VS的输出栏捕获
可以用_Debug宏把代码限定为非Release
一个参考
#ifdef __SC_DEBUG__
class DEBUG_PAINT {
private :
static const LENGTH BUFFER_SIZE = 1024 ;
private :
STR mBuffer[BUFFER_SIZE] ;
INDEX mWrite ;
public :
DEBUG_PAINT () {
mWrite = 0 ;
}
~DEBUG_PAINT () {
if (mWrite > 0) {
mBuffer[mWrite++] = STR ('\n') ;
mBuffer[mWrite] = STR ('\0') ;
#ifdef OutputDebugString
OutputDebugString (mBuffer) ;
#endif
}
}
inline DEBUG_PAINT &operator<< (VAR b) {
STR tmp[sizeof (VAR) + 1] ;
INDEX iw = sizeof (VAR) ;
const BOOL nagetive = b < 0 ;
if (nagetive)
b = -b ;
tmp[iw--] = 0 ;
while (b != 0) {
tmp[iw--] = b % 10 + STR ('0') ;
b /= 10 ;
}
if (iw + 1 == sizeof (VAR))
tmp[iw--] = STR ('0') ;
if (nagetive)
tmp[iw--] = STR ('-') ;
*this << &tmp[iw + 1] ;
return *this ;
}
inline DEBUG_PAINT &operator<< (PCSTR b) {
for (INDEX i = 0 ; mWrite < BUFFER_SIZE - 2 && b[i] != STR ('\0') ; i++)
mBuffer[mWrite++] = b[i] ;
return *this ;
}
} ;
#endif
------解决思路----------------------
楼主为什么不看看Win32 sdk自带的例子代码呢?
Debugging Functions
The following functions are used with debugging.
ContinueDebugEvent
DebugActiveProcess
DebugBreak
FatalExit
FlushInstructionCache
GetThreadContext
GetThreadSelectorEntry
IsDebuggerPresent
OutputDebugString
ReadProcessMemory
ReadProcessMemoryVlm
SetDebugErrorLevel
SetThreadContext
WaitForDebugEvent
WriteProcessMemory
WriteProcessMemoryVlm