Nuta
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować się zalogować lub zmienić katalog.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Aplikacja trybu użytkownika może włączyć źródło błędów , wywołując metodę WHEAErrorSourceMethods::EnableErrorSourceRtn .
Poniższy przykład kodu pokazuje, jak włączyć źródło błędów.
IWbemServices *pIWbemServices;
ULONG ErrorSourceID;
BSTR ClassName;
BSTR MethodName;
HRESULT Result;
IWbemClassObject *pClass;
IWbemClassObject *pInParametersClass;
IWbemClassObject *pInParameters;
IWbemClassObject *pOutParameters;
VARIANT Parameter;
ULONG Status;
// 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.
// The following also assumes that the ErrorSourceID
// variable has previously been initialized with the
// identifier of the error source to be enabled.
// Specify the class and method to execute
ClassName = SysAllocString(L"WHEAErrorSourceMethods");
MethodName = SysAllocString(L"EnableErrorSourceRtn");
// Get the class object for the method definition
Result =
pIWbemServices->GetObject(
ClassName,
0,
NULL,
&pClass,
NULL
);
// Get the input parameter class object for the method
Result =
pClass->GetMethod(
MethodName,
0,
&pInParametersClass,
NULL
);
// Create an instance of the input parameter class
Result =
pInParametersClass->SpawnInstance(
0,
&pInParameters
);
// Set the ErrorSourceId parameter
Parameter.vt = VT_UI4;
Parameter.ulVal = ErrorSourceId;
Result =
pInParameters->Put(
L"ErrorSourceId",
0,
&Parameter,
0
);
VariantClear(&Parameter);
// Call the EnableErrorSourceRtn method indirectly by
// calling the IWbemServices::ExecMethod method.
Result =
pIWbemServices->ExecMethod(
ClassName,
MethodName,
0,
NULL,
&pInParameters,
&pOutParameters,
NULL
);
// Get the status from the output parameters object
Result =
pOutParameters->Get(
L"Status",
0,
&Parameter,
NULL,
NULL
);
Status = Parameter.ulval;
VariantClear(&Parameter);
// Free up resources
SysFreeString(ClassName);
SysFreeString(MethodName);
pInParameters->Release();
pInParametersClass->Release();
pClass->Release();
pOutParameters->Release();
Aplikacja trybu użytkownika może wyłączyć źródło błędów przez wywołanie metody WHEAErrorSourceMethods::DisableErrorSourceRtn. Aby uzyskać więcej informacji na temat wyłączania źródła błędów, zobacz Wyłączanie źródła błędów.