获取错误注入功能
注意
WHEA 错误注入接口需要具有 EINJ ACPI 表的计算机或实现 错误注入功能区域的 PSHED Plug-In。 大多数使用者系统不包含 EINJ 实现,并且 Windows 没有内置的 PSHED Plug-In来启用错误注入。 如果这两者都不存在,错误注入接口将返回错误。
用户模式应用程序可以通过调用 WHEAErrorInjectionMethods::GetErrorInjectionCapabilitiesRtn 方法获取有关硬件平台的错误注入功能的信息。 此方法返回描述硬件平台支持的错误注入功能的 WHEA_ERROR_INJECTION_CAPABILITIES 结构。
以下代码示例演示如何检索错误注入功能信息。
IWbemServices *pIWbemServices;
BSTR ClassName;
BSTR MethodName;
HRESULT Result;
IWbemClassObject *pOutParameters;
VARIANT Parameter;
ULONG Status;
WHEA_ERROR_INJECTION_CAPABILITIES ErrorInjectionCapabilities;
// The following example assumes that the application
// has previously connected to WMI on the local machine
// and that the pIWbemServices variable contains the
// pointer that was returned from the call to the
// IWbemLocator::ConnectServer method.
// Specify the class and method to execute
ClassName = SysAllocString(L"WHEAErrorInjectionMethods");
MethodName = SysAllocString(L"GetErrorInjectionCapabilitiesRtn");
// Call the GetErrorInjectionCapabilitiesRtn method indirectly
// by calling the IWbemServices::ExecMethod method.
Result =
pIWbemServices->ExecMethod(
ClassName,
MethodName,
0,
NULL,
NULL,
&pOutParameters,
NULL
);
// Get the status from the output parameters object
Result =
pOutParameters->Get(
L"Status",
0,
&Parameter,
NULL,
NULL
);
Status = Parameter.ulVal;
VariantClear(&Parameter);
// Get the capabilities from the output parameters object
Result =
pOutParameters->Get(
L"Capabilities",
0,
&Parameter,
NULL,
NULL
);
ErrorInjectionCapabilities.AsULONG = Parameter.ulVal;
VariantClear(&Parameter);
// Process the error injection capabilities data
...
// Free up resources
SysFreeString(ClassName);
SysFreeString(MethodName);
pOutParameters->Release();