Home › Forums › TWAIN Classic › Need to fetch connected scanners serial number
- This topic is empty.
- AuthorPosts
- Rajan Chadha
Hi All,
I want to fetch the serial number of all the connected scanners using EzTwain 3 and Java Language
While searching solution I came to know that this can be possible via CAP_SERIALNUMBER capability but I am not able to fetch it using CAP_SERIALNUMBER capability. Everytime I ran the code it returns a random number. Following is the code snippet for the same.
Please provide some solution (in Java or C# language) to fetch serial number or an example of how CAP_SERIALNUMBER capability can be used to do the same.
private boolean initializeScanner() {
boolean imageSourceSelected = false;
final EZTwain ezTwainInstance = EZTwain.INSTANCE;
final boolean isTwainAvailable = ezTwainInstance
.TWAIN_IsAvailable();if (isTwainAvailable) {
logger.info(“Twain is available”);
final boolean sourceManagerLoaded = ezTwainInstance
.TWAIN_LoadSourceManager();if (sourceManagerLoaded) {
ezTwainInstance.TWAIN_DisableParent(false);
final boolean sourceMgrOpened = ezTwainInstance
.TWAIN_OpenSourceManager(0);
if (sourceMgrOpened) {
final String selectScannerName = ezTwainInstance
.TWAIN_DefaultSourceName();
logger.info(“Default Scanner name is :”
+ selectScannerName);
imageSourceSelected = ezTwainInstance
.TWAIN_OpenSource(selectScannerName);
if (imageSourceSelected) {
int getCap16 = ezTwainInstance.TWAIN_GetCapUint16(ezTwainInstance.CAP_SERIALNUMBER, EZTwain.TWTY_INT16);
logger.error(“@@@@@initialiseDefault Scanner Selected is :”
+ selectScannerName + ” getCap16 ” + getCap16);
int getCap32 = ezTwainInstance.TWAIN_GetCapUint32(ezTwainInstance.CAP_SERIALNUMBER, EZTwain.TWTY_INT32);
logger.error(“@@@@@initialiseDefault Scanner Selected is :”
+ selectScannerName + ” getCap32 ” + getCap32);
int get = ezTwainInstance.TWAIN_Get(ezTwainInstance.CAP_SERIALNUMBER);
logger.error(“@@@@@initialiseDefault Scanner Selected is :”
+ selectScannerName + ” get ” + get);
int getCurrent = ezTwainInstance.TWAIN_GetCurrent(ezTwainInstance.CAP_SERIALNUMBER);
logger.error(“@@@@@initialiseDefault Scanner Selected is :”
+ selectScannerName + ” getCurrent ” + getCurrent);int getDefault = ezTwainInstance.TWAIN_GetDefault(ezTwainInstance.CAP_SERIALNUMBER);
logger.error(“@@@@@@initialseDefault Scanner Selected is :”
+ selectScannerName + ” getDefault ” + getDefault);
final boolean isFeederLoaded= ezTwainInstance.TWAIN_IsFeederLoaded();
selectedScannerName = selectScannerName;}
}
}
}
return imageSourceSelected;
}MarkDespite the name the serial number is a string, I think it’s defined in the spec as TW_STR255.
- AuthorPosts