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

📄 error.cxx

📁 MICO2.3.13 corba 环境平台
💻 CXX
字号:
/*+----------------------------------------------------------------------------

Microsoft Windows Sample Program
Copyright (C) 1994 - 1997 Microsoft Corporation.  All rights reserved.

FILE:       error.cxx

PURPOSE:    Demonstrates how to get the message text for an error code from
            the system resources.

FUNCTIONS:  PrintErrorMessage - Prints the message text for an error code.

-----------------------------------------------------------------------------*/
#include <windows.h>
#include <stdio.h>

//+---------------------------------------------------------------------------
//
//  Function:   PrintErrorMessage
//
//  Synopsis:   Prints the message text for the specified error code.
//
//  Notes:      PrintErrorMessage uses FormatMessage to get the message
//              text from the system resources.
//
//----------------------------------------------------------------------------
void PrintErrorMessage(HRESULT hr)
{
  DWORD cMsgLen;
  char *pszErrorMessage = 0; /* buffer for message text from system */

  /* get the text description for that error number from the system */
  cMsgLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, 
                          0, 
                          (DWORD) hr,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
                          (LPTSTR) &pszErrorMessage, 
                          512,
                          0);

    if(cMsgLen > 0)
    {
        printf("Error %x: %s\n", hr, pszErrorMessage);
        LocalFree((HLOCAL) pszErrorMessage);
    }
    else
    {
        printf("Error %x\n", hr);
    }
}

⌨️ 快捷键说明

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