Platform and Device Identification in Software
26 Aug 2022
Note: This information is provided as a reference and does not imply that Juniper Systems will be able to provide full support for the use of any specific third-party software with a Juniper Systems product.
Identifying the platform can be useful to ensure software compatibility. Similarly, uniquely identifying individual devices can be useful for software licensing (copyright protection).
- Windows
- Android
- Archive from 2012 - Windows Embedded Handheld (formerly Windows Mobile) or Windows CE
Android
With the Mesa 3 Android platform, the following code can be used to programmatically obtain the platform model, device serial number, and RFID configuration.
private String GetProperty(String p)
{
String line;
try {
Process process = Runtime.getRuntime().exec("getprop ro.juniper." + p);
BufferedReader buf = new BufferedReader(new InputStreamReader(process.getInputStream()));
line = buf.readLine();
buf.close();
} catch (Exception e) {
// Do nothing - can't get property value
line = "<Exception>";
}
return line;
}
...
...
...
tv = findViewById(R.id.unitSerial);
tv.setText(GetProperty("unitserial"));
tv = findViewById(R.id.modelNumber);
tv.setText(GetProperty("modelid"));
tv = findViewById(R.id.rfidConfig);
tv.setText(GetProperty("rfid"));
With the Allegro 3 and Archer 3 platform, the following code can be used to programatically obtain the platform model and device serial number.
TextView tv;
tv = findViewById(R.id.model);
tv.setText(Build.MODEL);
tv = findViewById(R.id.serial);
tv.setText(Build.SERIAL);
Microsoft Windows
In the Microsoft Windows operating system (starting at Windows 10 Pro version 1607 (Anniversary Update) and later), such as on our Mesa Pro, Mesa 3 Windows, and Mesa 2 tablet PC models, a general method for the platform and unique device identification is described at the following web pages.
https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemfirmwaretable
https://docs.microsoft.com/en-us/uwp/api/windows.system.profile.systemidentification
An example is as follows.
var idInfo = Windows.System.Profile.SystemIdentification.GetSystemIdForPublisher();
if (idInfo?.Id != null)
{
using (var reader = DataReader.FromBuffer(idInfo.Id))
{
var bytes = new byte[idInfo.Id.Length];
reader.ReadBytes(bytes);
var id = BitConverter.ToString(bytes);
}
}
Retrieve the Serial Number
There are several ways to query the serial number of the unit.
- Juniper-specific info DLL (M2DllInfo.dll, M3DllInfo.dll, ST1DllInfo.dll, or MS4DllInfo.dll), and using this function:
bool GetSerialNumber( char* pSerialNumber, DWORD * pdwStrLen);
- Powershell command:
(Get-WmiObject -Class Win32_ComputerSystemProduct).IdentifyingNumber
- wmic (Oct. 2023—This still works; although it has been deprecated.)
WMIC BIOS get serialnumber
Retrieve our unique serial number for a device using the sample code from Windows SDK (Software Development Kit) for Mesa tablets.
Updated—October 2023
The Juniper-specific info DLL should return our unique Serial Number that is saved in the BIOS. If you are using C# you could PInvoke this function if needed. Otherwise, we previously recommended using wmic.
The following command returns our unique serial number that is recorded in a few bits of the following Windows registry key.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mssmbios\Data]
SMBiosData BINARY
Microsoft Windows Embedded Handheld (formerly Windows Mobile)
One location in the Windows registry that contains such information by default is [HKEY_LOCAL_MACHINE\Ident], though that information can be changed by the user. More permanent identity information can be obtained using the methods described in the sections below.
Platform Identification
Some methods to identify the platform (Allegro 2, Archer 2, Mesa, TK6000, classic Archer, Allegro MX, CX, CE, etc.) on which your software is running include the following.
Microsoft API
Microsoft has an API that will work on our Windows Embedded Handheld (formerly Windows Mobile) handhelds as explained at the following webpage.
http://msdn.microsoft.com/en-us/library/aa932539.aspx
Specifically, using the SPI_GETPLATFORMNAME Parameter will return a simple identifier such as "Allegro MX" or "Archer".
Juniper Systems API (JSAPI)
We provide an API for identifying our newer Microsoft Windows Mobile 6.1 handhelds (failure to load this DLL for this API could also possibly be used to identify our older handhelds or operating systems) as explained at the following webpage.
For our Allegro product models, successfully loading the DLL for our now deprecated Allegro APIs (which has since been replaced by JSAPIs) could identify our older handheld platforms as explained at the following webpage.
Device Identification
The functions described below are to be used when developing software to identify each individual Field PC device to which the software has been installed. This can be useful when creating software licensing (for copyright protection), confirming that the correct version of software is being installed, and other needs requiring the identification of specific devices.
Windows Mobile Field PCs
Microsoft recommends to use the GetDeviceUniqueID() function that was incorporated into all Windows Mobile 5.0 and newer devices (though it has become more standard on Windows Mobile 6.0 and newer devices). Using this function prevents the need for software developers to create different unique builds of their software application or having to incorporate multiple methods simply for identifying individual devices from different device manufacturers.
This function returns a 16-byte code derived from hardware specific information that is unique to each device. For more information, please visit the following website:
http://msdn2.microsoft.com/en-us/library/ms893522.aspx
Additional information can also be obtained from:
http://blogs.msdn.com/windowsmobile/archive/2006/01/09/510997.aspx
The GetDeviceUniqueID() function returns a "hash" of the manufacturer assigned serial number and other information to give each device a unique number. It is unique to each device, but it is not the serial number assigned to each device by Juniper Systems.
If you are writing software specific to our Windows Mobile Field PCs, or have pre-existing software which already uses the multiple, varied methods for retrieving the individual serial number from different hardware device manufacturers, you can programmatically identify the Juniper Systems assigned hardware serial number using the JSAPI GetSerialNumber function as explained at our Custom APIs (Application Programming Interfaces) developer links.
Alternatively, it is possible to call the unique ID from an inserted card (like an SD card) so software can be locked to only the device that currently has that specific card inserted (which could be moved between devices when needed). Though this currently requires access to some low-level function calls which are normally only provided to device manufacturers (Platform Builder).
Windows CE Field PCs (Allegro CX and older, not Allegro 2 or MX)
To determine the platform, call SystemParametersInfo(uiAction, uiParam, pvParam, 0) with uiAction equal to SPI_GETPLATFORMTYPE. The uiParam parameter specifies the length of the buffer in pvParam, which on successful return will contain Allegro F/PC (Allegro CE/DOS), Allegro CE, or Allegro CX (depending on the Allegro you are using) in Unicode characters.
To get the serial number, the Allegro contains a unique DLL called "AllegroAPI" that provides functions such as one to return the serial number. The "GetAllegroSerialNumber" function in the AllegroAPI.dll is as follows:
ALEGROAPI BOOL AllegroGetSerialNumber( PTCHAR szSerialString, PDWORD pdwLen );
The AllegroGetSerialNumber function returns the unique serial number of the device in a zero-terminated, fixed length (leading zeros) character string. If you only want to know the length of the serial number (to allocate space, for example) pass NULL for szSerialString.
Below is a sample of some C++ code for getting the serial number.
#include "AllegroAPI.h"
TCHAR serialID[10];
DWORD dwLen = sizeof(serialID); AllegroGetSerialNumber(serialID,&dwLen);
The Allegro SDK must be used and the AllegroAPI.lib must be added to the linker under Project\Settings and Link Tab. The AllegroAPI.dll is on the Allegro in the Windows directory, but is not viewable to the user, even when viewing hidden files. Calling the above function will work. The same function is called for viewing the Device Name in the Control Panel under Communications or System.
If using Embedded Visual Basic or a Microsoft .NET programming language, you will need to P/Invoke the AllegroGetSerialNumber function. You will need to declare the header similar to:
[DllImport("AllegroAPI.dll", SetLastError=true)]
private static extern bool AllegroGetSerialNumber(ref
StringBuilder szSerialString, ref long pdwLen);