Skip to content

OnDeviceArrivalOrRemoval

event

Delphi
property OnDeviceArrivalOrRemoval: TOnDeviceArrivalOrRemoval read FOnDeviceArrivalOrRemoval write Set_OnDeviceArrivalOrRemoval;
C++Builder
__property TOnDeviceArrivalOrRemoval OnDeviceArrivalOrRemoval = {read=FOnDeviceArrivalOrRemoval, write=Set_OnDeviceArrivalOrRemoval};
typedef void __fastcall (__closure *TOnDeviceArrivalOrRemoval)(System::TObject* Sender, bool IsDeviceArrival, bool IsVideoDevice, System::UnicodeString DeviceName, System::LongInt DeviceIndex);
C#
public event OnDeviceArrivalOrRemovalEventHandler OnDeviceArrivalOrRemoval;
public delegate void OnDeviceArrivalOrRemovalEventHandler(object sender, TOnDeviceArrivalOrRemovalEventArgs e);
VB.NET
Public Event OnDeviceArrivalOrRemoval As OnDeviceArrivalOrRemovalEventHandler
Public Delegate Sub OnDeviceArrivalOrRemovalEventHandler(sender As Object, e As TOnDeviceArrivalOrRemovalEventArgs)
C++/Qt
void SetOnDeviceArrivalOrRemoval (TOnDeviceArrivalOrRemovalCb OnDeviceArrivalOrRemovalCb);
typedef void CALLBACK TOnDeviceArrivalOrRemovalCb (void *Object, void *Sender, BOOL IsDeviceArrival, BOOL IsVideoDevice, wchar_t *DeviceName, int DeviceIndex);

This TOnDeviceArrivalOrRemoval event occurs each time a video or audio capture device is plugged in or removed, and returns information about this device: audio or video device, connected or disconnected, device name.

The event occurs whatever the VideoSource. It also occurs when an audio capture device is enabled or disabled in the Windows sound settings, or when a microphone is plugged into or removed from a jack (with the sound cards that report it).

The VideoDevices or AudioDevices list is updated when a new capture device is plugged in.

A video capture device that is unplugged remains in the list. To determine whether a device is connected, test the IsVideoDeviceConnected (DeviceIndex: LongInt): Boolean function, which returns false after the device removal.

When the video capture device is plugged in again, even into another USB port, it keeps its index and IsVideoDeviceConnected returns true again.

Use IsAudioDeviceConnected to test the audio devices of the AudioDevices list.

Note: device arrival/removal detection works only with WDM drivers; "old" VFW capture devices always appear in the device lists, even if not connected.