ITracing::SetTraceLevel 方法 (wdtf.h)
SetTraceLevel 方法會設定對象的追蹤層級。 WDTF 物件模型中的每個物件都應該支援 setTraceLevel 方法
語法
HRESULT SetTraceLevel(
[in] TTraceLevel Level
);
參數
[in] Level
這個物件的新 TTraceLevel 值。
傳回值
SetTraceLevel 會傳回標準 HRESULT 值。
言論
如需追蹤層級的詳細資訊,請參閱 TTraceLevel 和 ITracer。
使用 Trace_Default 層級,將物件設定回物件共同類別登錄中定義的設定。
由於 IAction 介面繼承自 ITracing 介面,因此所有 WDTF Actions 都會支援 setTraceLevel 。 所有 WDTF 核心介面 也應該支援此方法。
下列程式代碼範例示範如何使用 SetTraceLevel 方法。
VBScript
'
' Get DeviceManagement Action interface for the target
'
Set Action = CDROM.GetInterface("DeviceManagement")
If Err.number <> 0 Then
WScript.Echo Space(4) & "Failed to get interface DeviceManagement. Error Number:" & Err.number
Else
'
' Set the tracing level to HIGH
'
Action.SetTraceLevel(Trace3_High)
If Err.number <> 0 Then
WScript.Echo Space(4) & "Failed to set tracing level to 'High'. Error Number:" & Err.number
End If
'
' Disable the CD-ROM
'
WScript.Echo Space(4) & "Trying to disable device..."
Action.Disable()
If Err.number <> 0 Then
WScript.Echo Space(4) & "Failed to disable the specified CDROM. Error Number:" & Err.number & vbcrlf
Else
WScript.Echo Space(4) & "Specified CDROM successfully disabled." & vbcrlf
End If
End If
C++
IDevMan* pDevMan; // DeviceManagement Action interface
VARIANT vtEmpty; // To be passed as a parameter to ITarget::GetInterface
VariantInit(&vtEmpty);
//
// Get DeviceManagement Action interface
//
hr = pCDROM->GetInterface(L"DeviceManagement", vtEmpty, vtEmpty, (IAction**)(&pDevMan));
if(FAILED(hr))
{
_tprintf(_T("\n Failed to get DeviceManagement Interface for specified CDROM Device. Error: 0x%x"), hr);
goto Cleanup;
}
//
// Set the trace level to High
//
hr = pDevMan->SetTraceLevel(Trace3_High);
if(FAILED(hr))
{
_tprintf(_T("\n Failed to set tracing level to 'High'. Error: 0x%x"), hr);
}
//
// Disable the CD-ROM
//
_tprintf(_T("\n Trying to disable device..."));
hr = pDevMan->Disable();
if(FAILED(hr))
{
_tprintf(_T("\n Failed to disable the specified CDROM. Error: 0x%x"), hr);
}
else
{
_tprintf(_T("\n Specified CDROM successfully disabled."));
}
要求
要求 | 價值 |
---|---|
目標平臺 | 桌面 |
標頭 | wdtf.h |