如何检测Windows Mobile 5设备序列号? (.NET CF 3.5)
我工作的地方有多种设备(主要是 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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我首先尝试 P/Invoke 获取设备 ID(
KerneIoControl
和IOCTL_HAL_GET_DEVICEID
),并查看它是否与您要查找的序列号匹配。 这是一个示例。I'd start by trying to P/Invoke to get the device ID (
KerneIoControl
withIOCTL_HAL_GET_DEVICEID
) and see if it matches the serial number you're after. Here's an example.我不了解您的 Datalogic 4420 Falcon 设备,但我使用 Intermec CK30 & CK60 和我有他们的 itc50.dll 文件。
这是片段:
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: