如何检测的Windows Mobile 5设备序列号? (.NET CF 3.5)序列号、设备、Mobile、Windows

2023-09-04 06:18:25 作者:暗幽天魔

我们已经在我工作的几个设备(主要是 Datalogic的4420猎鹰 ),有人总是留下一关的基础。电池干涸,然后他们把他们带回得到安装全部结束。 (这里应该是一个方法来配置SD卡重新加载时这样的错误上的一个文件,但它并不能很好地工作)

We have several devices where I work (mostly Datalogic 4420 Falcon), 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)

当有人保存在设备上的改变(使用我的应用程序,将数据写入到SQL Server),该序列号是与它一起,所以我们可以跟踪哪些设备正在使用,其中发送的。

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.

每个设备都有一个序列号,我必须以物理(即手动)编写成设备名称字段,我可以读。工作code在这里,如果有人想知道如何:

Each device has a Serial Number, and I have to physically (i.e. manually) write that into the Device name field, which I can read. Working code here if anyone wants to know how:

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;
  }
}

我不喜欢手动(即胖手指容易)序列号输入。有一些电话查询设备的序列号,或者是供应商特定的?

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?

的Datamax确实让一个SDK是专门针对他们的设备,但我们不希望我们的应用程序捆绑到任何一个制造商(我们已经被绑在VS2008)。

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 / Invoke来获取设备ID(启动 KerneIoControl IOCTL_HAL_GET_DEVICEID ),看看它是否你后的序列号相匹配。 下面是一个例子。

I'd start by trying to P/Invoke to get the device ID (KerneIoControl with IOCTL_HAL_GET_DEVICEID) and see if it matches the serial number you're after. Here's an example.