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

发布于 2024-11-30 20:55:35 字数 1134 浏览 0 评论 0原文

我工作的地方有多种设备(主要是 Datalogic 4420 Falcon),总有人会离开基地。电池电量耗尽,然后他们将它们带回来重新安装。 (应该有一种方法可以配置 SD 卡上的文件以在出现此类错误时重新加载,但效果不是很好)

当有人在设备上保存更改时(使用我的将数据写入 SQL Server 的应用程序) ,序列号随之发送,以便我们可以跟踪哪些设备在哪里使用。

每个设备都有一个序列号,我必须将其物理(即手动)写入到我可以读取的设备名称字段中。如果有人想知道如何操作,请在此处使用代码:

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

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

Datamax 确实制作了一个特定于其设备的 SDK,但我们不希望我们的应用程序与任何一家制造商绑定(我们已经与 VS2008 绑定)。

在此处输入图像描述

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)

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.

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 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).

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风柔一江水 2024-12-07 20:55:35

我首先尝试 P/Invoke 获取设备 ID(KerneIoControlIOCTL_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.

时光礼记 2024-12-07 20:55:35

我不了解您的 Datalogic 4420 Falcon 设备,但我使用 Intermec CK30 & CK60 和我有他们的 itc50.dll 文件。
这是片段:

[DllImport("itc50.dll")]public static extern int ITCGetSerialNumber(StringBuilder Snumber, int buffSize);

StringBuilder hwSN = new StringBuilder(12);

if (ITCGetSerialNumber(hwSN, hwSN.Capacity) >= 0)
{
    ;
    ;
}

I don't know about your Datalogic 4420 Falcon device, but I work with Intermec CK30 & CK60 and I have their itc50.dll file.
Here is snippet:

[DllImport("itc50.dll")]public static extern int ITCGetSerialNumber(StringBuilder Snumber, int buffSize);

StringBuilder hwSN = new StringBuilder(12);

if (ITCGetSerialNumber(hwSN, hwSN.Capacity) >= 0)
{
    ;
    ;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文