共用方式為


取得錯誤注入能力

備註

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();