// ScanAPI Helper provides a series of Callbacks // indicating some asynchronous events has occurred #region ScanApiHelperNotification Members // a scanner has connected to the host public void OnDeviceArrival(long result, ScanApiHelper.DeviceInfo newDevice) { if (SktScanErrors.SKTSUCCESS(result)) { UpdateStatusText("New Scanner: " + newDevice.Name); _device = newDevice; // This is for the Host Acknowledgment feature. These lines can // be safely removed from #if to the #endif from your application // if this feature is not needed #if HOSTACK // Set the device to NOT acknowledge itself _scanApiHelper.PostSetLocalAcknowledgement(_device, false, null); // And make sure it does not give any indication after a scan _scanApiHelper.PostSetDecodeAction(_device, ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionNone, null); #else // Set the device to NOT acknowledge itself _scanApiHelper.PostSetLocalAcknowledgement(_device, true, null); // And make sure it does not give any indication after a scan int decode = ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionBeep | ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionFlash | ISktScanProperty.values.localDecodeAction.kSktScanLocalDecodeActionRumble; _scanApiHelper.PostSetDecodeAction(_device, decode, null); #endif } else { string strMsg = String.Format("Unable to open scanner, error = {0}.", result); MessageBox.Show(strMsg, strAppName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void onGetScanApiVersion(long result, ISktScanObject scanObj) { if (SktScanErrors.SKTSUCCESS(result)) { StringBuilder version = new StringBuilder("ScanAPI Version: "); version.AppendFormat("{0:x}.{1:x}.{2:x}.{3:x} {4:x}/{5:x2}/{6:x2} {7:x}:{8:x}", scanObj.Property.Version.Major, scanObj.Property.Version.Middle, scanObj.Property.Version.Minor, scanObj.Property.Version.Build, scanObj.Property.Version.Month, scanObj.Property.Version.Day, scanObj.Property.Version.Year, scanObj.Property.Version.Hour, scanObj.Property.Version.Minute); info.Text = version.ToString(); } }
// ScanAPI is now initialized and fully functional // (ScanAPI has some internal testing that might take // few seconds to complete) public void OnScanApiInitializeComplete(long result) { UpdateStatusText("SktScanAPI " + (SktScanErrors.SKTSUCCESS(result) ? "opened!" : "failed!")); }