title: POS for .NET Barcode scanner DeviceEnabled failed to set
body: <p>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.</p>
  
  <p>I use the typical workflow to create a scanner instance in a WinForms project:</p>
  
  <pre><code>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;
    }
  }
  </code></pre>
  
  <p>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 <code>scanner.DeviceEnabled = true</code> statement, the following exception is thrown:</p>
  
  <pre><code>PosControlException: Failed to set property DeviceEnabled.
  </code></pre>
  
  <p>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. </p>
  
  <p>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?</p>
  
  <p>Environment:</p>
  
  <ul>
  <li>Windows 7 Pro x64</li>
  <li>.NET 4.5.1</li>
  </ul>
  
  <p>Thanks.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>After many hours, I have found the reason, it was registry virtualization. The OPOS driver (OCX) of the manufacturer tries to write to the <em>HKLM/Software/Wow6432Node/Intermec</em> subkey. So, that write access was virtualized to <em>HKEY_USERS/[User SID]_Classes/VirtualStore/Machine/Software/Wow6432Node/Intermec</em>. But the key in the virtual store was incomplete, many values were missing.</p>
  
  <p><strong>Solution:</strong> </p>
  
  <ul>
  <li>Delete the <em>HKEY_USERS/[User SID]_Classes/VirtualStore/Machine/Software/Wow6432Node/Intermec</em> key in the virtual store.</li>
  <li>Assign <em>Full access</em> permissions to the Windows <em>Users</em> group for the original <em>HKLM/Software/Wow6432Node/Intermec</em> key. So, all users access the identical registry key.</li>
  </ul>