我在调试一个win32 application, 我想找一个类似mfc中的trace那样的函数,请问有这样的函数么?

解决方案 »

  1.   

    void OutputDebugString(
      LPCTSTR lpOutputString
    );
      

  2.   

    //- --------------------
    // 以下是我常用的.
    int MyOutput(TCHAR *fmt, ...)
    {
        int n=0;
        static TCHAR msg[102400], *ptr;
        va_list args;    va_start(args, fmt);
        ptr = msg;#if defined(UNICODE)
        n = vswprintf(ptr, fmt, args);
    #else
        n = vsprintf(ptr, fmt, args);
    #endif
        va_end(args);
        OutputDebugString(msg);    return n;
    }
    //- --------------------
    用法:
    const TCHAR str = "hello";
    MyOutput("%s, 李逍遥\n", str);
      

  3.   

    #include <windows.h>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    OutputDebugString("lala");
    return 0;
    }这是我写的一个程序,在哪里看输出的信息啊?
      

  4.   

    最简单的:#Pragma message(“消息文本”)
      

  5.   

    按 F5 调试, 如果是 VC6 则在 Debug 窗口有 lala 这样的字符串.
    如果看不清楚 , 可以多换几行, 比如:
    OutputDebugString("\n\n -----------------lala -----------------\n");如果是 VS2005 , 则在 "输出" 窗口有打印