TBApiGetRelativeDevice API Call



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


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


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


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 also

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



Get device handle from position



Get position from device handle



Get device handle from position, excluding hidden (unplugged) devices



Get device handle from position, including hidden (unplugged) devices



Get device handle from named device



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;)



   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)