IDSFBus::Unplug Method

The Unplug method disconnects a simulated device from a simulated bus.

Syntax

HRESULT Unplug(
  [in]  DSFDevice *pDSFDevice
);

Parameters

  • pDSFDevice [in]
    The device to unplug.

Return Value

Unplug returns S_OK if the device is unplugged successfully. This method might also return E_INVALIDARG if the device is not a valid IDSFDevice object or if this device is not currently connected to the bus.

This method can also return many standard COM return values.

Remarks

You can use the IDSFBus::HotPlug method to plug the device into the first available port on the specified bus.

Examples

The following VBScript code example shows how to unplug a device from an IDSFBus object.

const IID_IDSFBus = "{E927C266-5364-449E-AE52-D6A782AFDA9C}" 

Dim LoopbackDev : Set LoopbackDev = WScript.CreateObject("SoftUSBLoopback.LoopbackDevice")
Dim Bus         : Set Bus = FindBus()

Bus.HotPlug LoopbackDev.DSFDevice

' Test the device here

Bus.Unplug LoopbackDev.DSFDevice

Private Function FindBus()

    Dim Dev : Set Dev = Nothing
    Dim Bus : Set Bus = Nothing
    Dim DSF : Set DSF = CreateObject("DSF.DSF")

    For Each Dev in DSF.Devices
        If Dev.HasObject(IID_IDSFBus) Then
            Set Bus = Dev.Object(IID_IDSFBus)
            If Not Bus Is Nothing Then
                Exit For
            End If
        End If
    Next

    Set FindBus = Bus

End Function

Requirements

Header

DSFif.h

See Also

IDSFBus

IDSFDevice

IDSFBus::HotPlug

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010