I'm currently developing a .NET 4.5.1 application that should use a barcode scanner to read 2D barcode text. For that, Microsoft POS for .NET 1.14.1 is installed and used. The barcode sanner (Intermec/Honeywell ED40) driver is correctly installed, the OPOS driver is an unmanaged OCX.
I use the typical workflow to create a scanner instance in a WinForms project:
public partial class MainForm : Form
{
private PosExplorer _explorer;
private Scanner _scanner;
public MainForm()
{
InitializeComponent();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
_explorer = new PosExplorer(this);
DeviceInfo device = myPosExplorer.GetDevice(DeviceType.Scanner, "Intermec_RS-232_Scanner");
_scanner = (Scanner)explorer.CreateInstance(device);
_scanner.Open();
_scanner.Claim(1000);
_scanner.DataEvent += scanner_DataEvent;
_scanner.ErrorEvent += scanner_ErrorEvent;
_scanner.DeviceEnabled = true; // throws here if normal user privileges
_scanner.DataEventEnabled = true;
_scanner.DecodeData = true;
}
}
Everything works fine if the application is started using administrative rights. But, if it is started using normal user rights, the scanner cannot be enabled. When executing the scanner.DeviceEnabled = true
statement, the following exception is thrown:
PosControlException: Failed to set property DeviceEnabled.
The same issue occurs, if I compile and start the provided Microsoft sample "Microsoft POS Tester". But the also provided, precompiled version "C:\Program Files (x86)\Microsoft Point Of Service\SDK\Samples\Sample Application\TestApp.exe" directory works, independent from the privileges.
I did not found a solution in different forums and in the POS for .NET documentation. I did several experiments with the Internet Explorer security settings for ActiveX, same problem. I guess, it is a security setting elsewere, has anybody an idea?
Environment:
Thanks.
Edit:
After many hours, I have found the reason, it was registry virtualization. The OPOS driver (OCX) of the manufacturer tries to write to the HKLM/Software/Wow6432Node/Intermec subkey. So, that write access was virtualized to HKEY_USERS/[User SID]_Classes/VirtualStore/Machine/Software/Wow6432Node/Intermec. But the key in the virtual store was incomplete, many values were missing.
Solution:
The problem is solved, see my edit above.