TScannerSensor is a class in the System.Sensors unit of the Delphi Standard Library that provides a component for accessing a scanner sensor on a device in a Delphi program. The TScannerSensor class is part of the System.Sensors.Components unit, which provides a set of components for accessing various types of sensors on a device, such as the light sensor, accelerometer, and GPS.
Here is an example of how you can use TScannerSensor in Delphi
First, include the System.Sensors and System.Sensors.Components units in your code by adding the following lines at the top of your program
1 2 3 |
uses System.Sensors, System.Sensors.Components; |
Declare a variable of type TScannerSensor
1 2 |
var ScannerSensor: TScannerSensor; |
Create an instance of TScannerSensor
1 |
ScannerSensor := TScannerSensor.Create(nil); |
Enable the scanner sensor
1 |
ScannerSensor.Active := True; |
Read the scanner data from the sensor
1 2 3 4 5 6 |
var ScannerData: TScannerData; begin ScannerData := ScannerSensor.Sensor.ScannerData; //Do something with the scanner data end; |
Disable the scanner sensor when you are done
1 |
ScannerSensor.Active := False; |
Finally, free the scanner sensor when it is no longer needed
1 |
ScannerSensor.Free; |
Keep in mind that the TScannerSensor class is designed to work with scanner sensors that are supported on the device. Not all devices have scanner sensors, and the specific capabilities of the scanner sensor may vary from device to device. You will need to refer to the documentation for the specific device you are using to learn more about its scanner sensor capabilities.
You can find more information about TScannerSensor in the Delphi documentation.
Leave a Reply