Open method

The Open method initializes the SimpleIO interface.

Syntax

HRESULT Open();

Parameters

This method has no parameters.

Return value

Open returns a standard HRESULT value. It should return extended error information as appropriate. The types of errors that Open can return are target-specific.

Remarks

You should call the Open method before calling the SimpleIO::RunIO method.

The following code example demonstrates how to use the SimpleIO::Open method.

VBScript

' ABSTRACT:
'    This procedure performs SimpleIO on the specified Target. 
' PARAMETER:
'    Target -  The target object that SimpleIO will be performed on.
 
Sub DoSimpleIO(Target)
    Dim SimpleIO_Action    ' SimpleIO Object
 
    On Error Resume Next

    Set SimpleIO_Action = Target.GetInterface("SimpleIO")

    If Err.Number <> 0 Then
        WScript.Echo "Failed to get SimpleIO interface from specified Target. Error: " & Err.Number
        Error.Clear
    Else
        WSCript.Echo "Found SimpleIO interface for specified Target."
 
        '
        ' Open
        '
        SimpleIO_Action.Open()
        If Err.Number <> 0 Then
            WScript.Echo "SimpleIO_Action.Open Failed for the specified Target. Error: " & Err.Number
            Error.Clear
        Else
            '
            ' Run IO
            '
            SimpleIO_Action.RunIO()
            If Err.Number <> 0 Then
                WScript.Echo "SimpleIO_Action.RunIo Failed for the specified Target. Error: " & Err.Number
                Error.Clear
            Else
                '
                ' Close
                '
                SimpleIO_Action.Close()
                If Err.Number <> 0 Then
                    WScript.Echo "SimpleIO_Action.Close Failed for the specified Target. Error: " & Err.Number
                    Error.Clear
                Else
                    WScript.Echo "SimpleIO Action successfully completed"
                End If
            End If
        End If
    End If
End Sub

C++

//+F
//
// FUNCTION: DoSimpleIO
// ABSTRACT:
//           Performs Simple IO on the Target
// PARAMETER:
//           ITarget* pVolume
//           [in] The address of the Target object that the IO needs to be performed on.
// RETURN: 
//          None
// 
//-F
HRESULT DoSimpleIO(ITarget* pTarget)
{
    HRESULT             hr = E_FAIL;    // Return value
    ISimpleIO_Action*   pSimpleIO;      // SimpleIO object
    VARIANT             vtEmpty;        // To be passed as parameter to ITarget::GetInterface
 
    VariantInit(&vtEmpty);
 
    hr = pTarget->GetInterface(L"SimpleIO", vtEmpty, vtEmpty, (IAction**)&pSimpleIO);
 if(FAILED(hr))
    {
        _tprintf(_T("\nFailed to get SimpleIO interface from specified Target. Error:0x%x"), hr);
 return hr;
    }

    hr = pSimpleIO->Open();
 if(FAILED(hr))
    {
        _tprintf(_T("\nSimpleIO::Open Failed for specified Target. Error:0x%x"), hr);
 return hr;
    }

    hr = pSimpleIO->RunIO();
 if(FAILED(hr))
    {
        _tprintf(_T("\nSimpleIO::RunIO Failed for specified Target. Error:0x%x"), hr);
 return hr;
    }

    hr = pSimpleIO->Close();
 if(FAILED(hr))
    {
        _tprintf(_T("\nSimpleIO::Close Failed for specified Target. Error:0x%x"), hr);
 return hr;
    }

 return hr;
}

See also

SimpleIO

SimpleIO::Close

SimpleIO::RunIO

 

 

Send comments about this topic to Microsoft

Build date: 1/30/2012