勇芳软件工作室.汉化:  Windows Management Instrumentation > COM API for WMI > Interfaces > IWbemStatusCodeText >

GetErrorCodeTex Method

Previous pageReturn to chapter overviewNext page

描述

 

IWbemStatusCodeText.GetErrorCodeText方法返回与错误代码相关联的文本字符串描述。

 

C++ 语法

 

HRESULT GetErrorCodeText(

[in]   HRESULT hRes,

[in]   LCID LocaleId,

[in]   long lFlags,

[out]  BSTR *MessageText

);

 

PowerBASIC 语法

 

METHOD GetErrorCodeText ( _

BYVAL hRes AS LONG, _

BYVAL LocaleId AS DWORD, _

BYVAL lFlags AS LONG, _

BYREF MessageText AS WSTRING _

) AS LONG

 

参数

 

hRes

 

处理您想要描述的错误代码。

 

LocaleId

 

保留。该参数必须为0(零)。

 

lFlags

 

保留。该参数必须为0(零)。

 

MessageText

 

指向包含错误代码描述文本的字符串。

 

返回值

 

如果成功,此方法返回WBEM_S_NO_ERROR。

 

示例代码

 

以下示例说明如何实现GetErrorCodeText.

 

IWbemStatusCodeText * pStatus = NULL;

 

SCODE sc = CoCreateInstance(CLSID_WbemStatusCodeText,

                              0, CLSCTX_INPROC_SERVER,

                              IID_IWbemStatusCodeText,

                              (LPVOID *) &pStatus);

 

if(sc == S_OK)

{

  BSTR bstr = 0;

 

  // The m_hres is an HRESULT variable that has already

  // been declared and initialized.

  sc = pStatus->GetErrorCodeText(m_hres, 0, 0, &bstr);

  if(sc == S_OK)

  {

      // to do, display this:

      SysFreeString(bstr);

      bstr = 0;

  }

  sc = pStatus->GetFacilityCodeText(m_hres, 0, 0, &bstr);

  if(sc == S_OK)

  {

      // to do, display this:

      SysFreeString(bstr);

      bstr = 0;

  }

  pStatus->Release();

}

 

// clean up.

pStatus->Release();

 

备注

 

要启用GetErrorCodeText返回文本字符串描述,调用者必须释放MessageText参数中的指针。

 

要求

 

客户

需要Windows Vista,Windows XP,Windows 2000 Professional,Windows NT Workstation 4.0 SP4及更高版本,Windows Me,Windows 98或Windows 95。

服务器

需要Windows Server 2008,Windows Server 2003,Windows 2000 Server或Windows NT Server 4.0 SP4及更高版本。

在Wbemcli.inc中声明

DLL

需要Wmiutils.dll。