取得錯誤插入功能
注意
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();