Share via


IDSFBus::HotPlug Method

The HotPlug method connects a simulated device to a simulated bus.

Syntax

HRESULT HotPlug(
  [in]  DSFDevice *pDSFDevice
);

Parameters

  • pDSFDevice [in]
    A pointer to a DSFDevice object that represents the device to connect to the bus.

Return Value

HotPlug returns S_OK if the device is attached to the bus successfully. This method might also return E_INVALIDARG if the device is not a valid DSFDevice object or if the device cannot be plugged into this bus type.

For USB controllers, this method will return E_INVALIDARG if the device is not powered or if the device is an external hub and it has one or more devices attached to it.

This method can also return many standard COM return values.

Remarks

The HotPlug method tries to plug the device into the first available port on the specified bus. Use the IDSFBus::Unplug method to disconnect the specified device from the bus.

Examples

The following VBScript code example shows how to connect a loopback device to a bus.

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

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

Bus.HotPlug LoopbackDev.DSFDevice

Private Function FindBus(SearchObjectGUID)

    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(SearchObjectGUID) Then
            Set Bus = Dev.Object(SearchObjectGUID)
            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::Unplug

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010