Before using any of the functions of RapidUSB interface DLL must be intinalized with call to UsbEnumerateDevices. After this friver can be requested to open handle of one of the devices enumerated during call to UsbEnumerateDevices. This is done with the help of the function OpenRapidUSB. It must be done once after starting the application. Also resources used by the driver should be cleaned up (CloseRapidUsb) before the application is closed.
Schematic session of using RapidUSB:
| // no RapidUSB devices present in system
|
| MessageBox("Cannot find any RapidUSB device!","Attention!", MB_OK | MB_ICONWARNING);
|
| // initialize(open) the driver
|
| // Check if the driver initialized successfully
|
| //////////////////////////////////////
|
| ///////// RapidUSB session //////////
|
| ///////// ................ //////////
|
| //////////////////////////////////////
|
| // Free resources used by the driver (close the driver)
|
| // An error happened while opening the driver
|
| MessageBox("Cannot open the driver","Attention!", MB_OK | MB_ICONWARNING);
|
Driver can be initialized by many applications simultaneously. The parameter of OpenRapidUSB() can be used to select a device supported by RapidUSB driver.
|