如何获取摩托罗拉(符号)移动设备序列号? [英] How to obtain a Motorola (Symbol) Mobile Device Serial Number?

查看:94
本文介绍了如何获取摩托罗拉(符号)移动设备序列号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取Motorola(符号)移动设备序列号?

How to obtain a Motorola (Symbol) Mobile Device Serial Number?

我正在编写带有"Symbol"库的Motorola ES400.

I'm programming the Motorola ES400 which comes with "Symbol" libraries.

似乎有一些方法可以获取各种扫描仪的序列号,而不是实际设备本身的序列号!

There seems to be ways of getting the serial numbers of the various scanners, but not of the actual device itself!

有人有什么主意吗?

TerminalInfo返回的序列号"(如设备上所示)和电子序列号"之间有什么区别?

Whats the difference between "serial number" (as shown on the device) and "electronic serial number" returned by TerminalInfo?

推荐答案

我只是在MC9090设备上进行了处理,该设备还使用了Symbol库(不确定它们是否相同,但是值得一试).我之所以使用反射,是因为我有来自不同制造商的设备,并且希望运行相同的代码.您可以直接从属性访问此字段,也可以使用反射:

I just dealt with this on the MC9090 device, which also uses the Symbol libraries (not sure if they are the same, but this is worth a shot). I used reflection because I have devices from different manufacturers and want the same code to run. You could access this field directly from the property or use reflection:

此处是属性所在:

Symbol.ResourceCoordination.Terminalinfo.ESN

这是我使用反射的方法:

Here is my method using reflection:

try
        {                   
                Assembly symbolApi = Assembly.LoadFrom("Symbol.ResourceCoordination.dll");      

                Type terminalInfo = null;

                foreach (Type t in symbolApi.GetTypes())
                {
                    if (t.Name == "TerminalInfo")
                    {
                        terminalInfo = t;                       
                        break;
                    }
                }

                LogService.log(terminalInfo.Name);

                if (terminalInfo != null)
                {
                    object objTerminalInfo = Activator.CreateInstance(terminalInfo);

                    PropertyInfo esn = null;
                    foreach (PropertyInfo info in terminalInfo.GetProperties())
                    {                           
                        if (info.Name == "ESN")
                        {
                            esn = info;
                            break;
                        }
                    }

                    if (esn != null)
                    {
                        object objSn = esn.GetValue(objTerminalInfo, null);
                        sn = objSn.ToString();
                    }
                }
                else
                    LogService.log("TerminalInfo type not found in " + symbolApi.FullName);

        }
        catch (MissingFieldException e)
        {               
            LogService.log("MissingFieldException, not Symbol Unit: " + e.Message);
        }
        catch (Exception e)
        {
            LogService.log("Error in SymbolAPI: " + e.Message);
        }

希望这会有所帮助!

这篇关于如何获取摩托罗拉(符号)移动设备序列号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆