TBApiGetRelativeDevice API Call

 

Description

Gets a device handle at a given position in the list of defined devices.

Parameters

An integer argument containing the device position offset. 0 = first device, 1 = second and so forth.

Returns

The device handle or a return value of TB_INVALID_HANDLE_VALUE meaning that the requested device does not exist.

Notes

This call is typically used to get the only device in a single device or if you want to iterate API calls through all controllers, Use other API calls to find a specific controller on the system, e.g. TBApiGetNamedDevice.

Applications should always call TBApiGetRelativeDevice before calling a specific API as it is possible that the Device Identifier could change if the controllers are reconfigured. See the Device page of the DCU configuration panel:

See also

A number of functions require a device handle. The following family of functions provide valid device handle’s:

 

TBApiGetRelativeDevice

Get device handle from position

 

TBApiGetRelativeDeviceFromHandle

Get position from device handle

 

TBApiGetNamedDevice

Get device handle from named device

 

TBApiGetDeviceFromSegment

Get device handle from segment

 

Visual C++ Declaration/example

 

HTBDEVICE TBAPI TBApiGetRelativeDevice(int o);

 

// Gets the first device on the system, you can use

HTBDEVICE device = TBApiGetRelativeDevice(0);

 

// …or to enumerate all devices e.g.

HTBDEVICE device = TBApiGetRelativeDevice(0);

for(int i=0; device != TB_INVALID_HANDLE_VALUE;)

{

   DoSomethingWithDevice(device);

   device = TBApiGetRelativeDevice(++i);

}

 

Visual Basic Declaration/example

 

Public Declare Function TBApiGetRelativeDevice Lib "TBapi" Alias "_DLL_TBApiGetRelativeDevice@4" (ByVal offset as Integer) As Byte

 

Dim device as Byte

device = TBApiGetRelativeDevice(1)

 

 

In the above examples, if the devices are configured as shown (see dialog above), the second device will return a device handle of 4.