title: How to detect Windows Mobile 5 Device Serial Number? (.NET CF 3.5)
body: <p>We have several devices where I work (mostly <a href="http://www.mobile.datalogic.com/product.aspx?idprod=1" rel="nofollow noreferrer">Datalogic 4420 Falcon</a>), and someone is always leaving one off the base. The battery runs dry, then they bring them back to get setup all over. (There's supposed to be a way to configure a file on the SD card to reload upon such an error, but it doesn't work very well)</p>
  
  <p>When someone saves changes on the device (using my app that writes data to the SQL Server), the Serial Number is sent along with it so we can track what devices are in use where.</p>
  
  <p>Each device has a <code>Serial Number</code>, and I have to physically (i.e. manually) write that into the <code>Device name</code> field, which I can read. Working code here if anyone wants to know how:</p>
  
  <pre><code>static string deviceId = null;
  
  public static string DeviceName {
    get {
      if (String.IsNullOrEmpty(deviceId)) {
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Ident", true)) {
          try {
            deviceId = key.GetValue("Name", "[Unnamed]").ToString();
          } catch (Exception e) {
            ErrorWrapper("GetDeviceName", e);
            deviceId = Dns.GetHostName();
          } finally {
            key.Flush();
            key.Close();
          }
        }
      }
      return deviceId;
    }
  }
  </code></pre>
  
  <p>I do not like the manual (i.e. Fat Finger prone) Serial Number entry. Is there some call to query the device's Serial Number, or is that vendor specific?</p>
  
  <p>Datamax does make an SDK that is specific to their devices, but we don't want our applications tied down to any one manufacturer (we are already tied down to VS2008).</p>
  
  <p><img src="https://i.stack.imgur.com/BnQEo.png" alt="enter image description here"></p>