⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.c

📁 书中的主要程序文件。在打开例题的.dsw文件后,请读者在 tools菜单下的 Options 的 Directories 标签中选择 Executable files
💻 C
字号:
/*++

Copyright (c) 1999-2000  G&G Lab Corporation

Module Name:

    debug.c

  Copyright (c) 1999-2000 G&G Lab Corporation.  All Rights Reserved.

--*/

#include "common.h"

#if DBG

/*++
Routine Description:

    This Routine will output a printf style string to the debugger.

Arguments:
    
    lpszFormat - printf() style formatting string.

    ..... - Other arguments to be formatted.

Return Value:
    
    NONE.
      
--*/
void __DbgOut__(LPTSTR lpszFormat, ...)
{
    TCHAR buf[256];
    va_list va;
    
    OutputDebugString(_T("GetAble: "));
    
    va_start(va, lpszFormat);
    wvsprintf(buf, lpszFormat, va);
    va_end(va);
    
    OutputDebugString(buf);
    OutputDebugString(_T("\n"));
}

/*++
Routine Description:

    This Routine will display the LastError in human readable 
    form when possible.

    If the return value is a 32-bit number, and falls in the range:
        ERROR_NO_ASSOCIATED_CLASS   0xE0000200 
    To
        ERROR_CANT_REMOVE_DEVINST   0xE0000232 
    The values defined in setupapi.h can help to determine the error.
    Start by searching for the text string ERROR_NO_ASSOCIATED_CLASS.
  
Arguments:
    
    ErrorName: Human readable description of the last Function called.

Return Value:
    
    NONE.
      
--*/
void DisplayError(TCHAR * ErrorName)
{
    DWORD Err = GetLastError();
    LPVOID lpMessageBuffer;
    
    if (FormatMessage( 
        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
        NULL, 
        Err,  
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR) &lpMessageBuffer,  
        0,  
        NULL ))
        __DbgOut__(_T("%s FAILURE: %s"),ErrorName,(char *) lpMessageBuffer);
    else
        __DbgOut__(_T("%s FAILURE: (0x%08x)"),ErrorName,Err);
    
    LocalFree( lpMessageBuffer ); // Free the buffer allocated by the system
    SetLastError(Err);
}


#endif //DBG



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -