Download Print this page

Socket ScanAPI Reference Manual page 125

Advertisement

Socket ScanAPI Reference
It is strongly recommended to use the macro SKTSUCCESS() in order to test the
result of an API. This macro returns true if the result is 0 or positive, and false
otherwise.
C/C++:
The ScanAPI error is defined by the type SKTRESULT. All the ScanAPI APIs returns a
SKTRESULT result.
Java and C#:
The ScanAPI error is defined as a long. All the ScanAPI APIs return a long result.
The SKTSUCCESS function is defined in the SktScanErrors class as well as the error
codes.
C/C++ example:
SKTRESULT
HandleDeviceArrival(
IN TSktScanObject* pScanObj
}
{
SKRESULT Result=ESKT_NOERROR;
SKTHANDLE hDevice=NULL;
// open the scanner
Result=SktScanOpen(pScanObj->Device.Guid,&hDevice);
// if the scanner is successfully open, then
// store its info into the application
// scanner list
if(SKTSUCCESS(Result))
{
Result=AddScanner(pScanObj->Device.szDeviceName,hDevice);
}
return
Result;
}
Java example:
private void
HandleDeviceArrival(ISktScanObject scanObject) {
String friendlyName=
String deviceGuid=scanObject.getMessage().getDeviceGuid();
long
type=scanObject.getMessage().getDeviceType();
ISktScanDevice device=
long
result=device.Open(deviceGuid);
if(SktScanErrors.SKTSUCCESS(result))
{
© 2013 Socket Mobile, Inc.
scanObject.getMessage().getDeviceName();
SktClassFactory.createDeviceInstance(_ScanApi);
// add the new device into the list
Device newDevice=
new
Device(friendlyName,device,type);
125/152

Advertisement

loading
Need help?

Need help?

Do you have a question about the ScanAPI and is the answer not in the manual?