I am working on an app that will obtain an X.509 certificate for a device that will be used to encrypt various configuration data. Ideally, this certificate would contain information that can be correlated with procurement records. Is there any way to read the device serial number or IMEI from a universal windows app?
As for UWP in general, to get a system unique id (not IMEI), you might want to check out these classes:
Windows.System.Profile.SystemIdentification
and
Windows.System.Profile.HardwareIdentification
E.g.: you can query a unique device id with:
var buffer = SystemIdentification.GetSystemIdForPublisher();
Which has the following remarks according to msdn:
The ID has the following characteristics:
Unique for every system
Can be created offline
Persists across rebooting, OS upgrades/reinstalls, and so on
Persists across hardware modifications
Available in OneCore
Available on the factory floor for licensing purposes
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.systemidentification.getsystemidforpublisher.aspx
Be aware that the return type is an IBuffer and produces some raw (non-string-like-readable) bytes so you might need to serialize that.
More info
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.systemidentification.aspx
and
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.hardwareidentification.aspx
It is not possible to get IMEI of another phone with phone number information, however you can get the device unique Id.
using Microsoft.Phone.Info;
object uniqueId;
var hexString = string.Empty;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
hexString = BitConverter.ToString((byte[])uniqueId).Replace("-", string.Empty);
MessageBox.Show("myDeviceID:" + hexString);
Reference
Related
I have created a watcher to connect to BarcodeScanner using Windows.Devices.PointOfService
var watcher = DeviceInformation.CreateWatcher(BarcodeScanner.GetDeviceSelector());
var id = "";
watcher.Added += async (sender, information) =>
{
id = information.Id;
var barcodeScanner = await BarcodeScanner.FromIdAsync(id);
...
}
information parameter contains all data releted to my barcodeScanner, but when i try to get it with FromIdAsync is always null.
Those are data contained into information
- information {Windows.Devices.Enumeration.DeviceInformation} Windows.Devices.Enumeration.DeviceInformation
EnclosureLocation null Windows.Devices.Enumeration.EnclosureLocation
Id "\\\\?\\HID#VID_0536&PID_02E1&MI_01#c&d907bf5&0&0000#{c243ffbd-3afc-45e9-b3d3-2ba18bc7ebc5}\\POSBarcodeScanner" string
IsDefault false bool
IsEnabled true bool
Kind DeviceInterface Windows.Devices.Enumeration.DeviceInformationKind
Name "3800G" string
+ Pairing {Windows.Devices.Enumeration.DeviceInformationPairing} Windows.Devices.Enumeration.DeviceInformationPairing
+ Properties {System.__ComObject} System.Collections.Generic.IReadOnlyDictionary<string, object> {System.__ComObject}
+ Native View 0x1d148140 <Information not available, no symbols loaded for Windows.Devices.Enumeration.dll> IUnknown *
This device is listed as enabled to be accessed with POS.
Where I'm wrong? I have tried also to create the watcher behind a button click, but nothigs change.
If the model name of the scanner you are using is "3800G" as in the question code, it may not be supported by Windows.Devices.PointOfService.
A list of supported models is below.
Supported Point of Service Peripherals
If you want to use it with Windows.Devices.PointOfService, please change it to the model described in this.
In Addition:
Unified POS standard and Windows® Embedded for Point of Service are OPOS/POS for.NET/JavaPOS API. It is not Windows.Devices.PointOfService API.
That model is not listed on Honeywell's site.
And, sales agencies in Japan may be displayed as sales ended. Probably it is an old model. It is better to switch to a new model.
For example, the USB HID Bar code scanner mode setting is described on page 21 of the detailed manual of 1900 series.
If this mode setting description is not in the 3800G manual, you can not use Windows.Devices.PointOfService API on 3800G.
If you can set it, you will be able to use it if you install a device driver corresponding to this mode.
#Luigi Saggese,
You must first put this scanner into USB HID Barcode Scanner Mode. Please see Page 1-3 of the Honeywell 3800g Users Guide for the programming code to put the scanner into this mode.
Once the scanner is in this mode, you should see a POS Barcode Scanner node in Windows Device Manager. The specific scanner will show up in Device Manager as POS HID Barcode Scanner since it is using an in-box class driver which supports the USB HID POS Scanner protocol. At this point it should work with your Watcher.
Terry Warwick, Microsoft
I need to get a unique id of video card adapter. When searching in the properties of the device (using Device Manager of Windows), I notice that there is a property named Hardware Ids as shown in image bellow.
I tried to get these Ids in my winform application. I found this method:
string VideoCardInfoID()
{
ManagementObjectSearcher objvide = new ManagementObjectSearcher("select * from Win32_VideoController");
string output = string.Empty;
foreach (ManagementObject obj in objvide.Get())
{
output += (obj["PNPDeviceID"] + "\n");
}
return output;
}
The output of this code is:
PCI\VEN_10DE&DEV_1055&SUBSYS_908A104D&REV_A1\4&F7451F8&0&0008
I have two questions:
Is PNPDeviceID of video card adapter unique across all machines? does it change when new fresh Windows installed? I know there some similar questions in stack overflow, but they does not contain a clear answers, such as this question and this question.
Why there is additional characters in the output of the c# function (\4&F7451F8&0&0008)?
Update: I try install new fresh Windows and the Hardware Ids and PNPDeviceID still the same, But I still don't know if PNPDeviceID unique across all machines (I mean the same as MAC address).
Is PNPDeviceID of video card adapter unique across all machines?
No. Essentially what this string is comprised of is
<Bus>\<Device ID>\<Instance ID>
The Instance ID is only unique within the context of the current system, and it may not even be unique for the whole system, only for the device's bus.
That is, if you have two identical video cards installed in the computer, they will have the same Device ID, but different Instance ID.
A graphics card driver might use its own serial number in the Instance ID. So it is possible that Instance ID is globally unique, but WMI cannot make that guarantee for all PNP devices.
At this point you will likely have to use a per-vendor documented way to determine the device's serial number, if at all possible.
The context is the following, we have multiple trucks that contains a bluetooth to serial device, we have given each truck bluetooth a unique name to be able to connect to a specific truck.
I use this code to retrieve all the RFComm services :
DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort))
The problem is that all the DeviceInformation objects returned contains the name of the RFComm service in the Name property instead of the bluetooth device name. When my project was a Win 8 store app, all was fine since the name property contained the bluetooth device name.
I found that I could create a BluetoothDevice object using the device id returned by the above code, but then the app ask to use the bluetooth device for all devices until I find the good one. I would like to prevent that as it wasn't the case with Win 8 store app.
Second solution I found was to parse the device id of the RFComm service which look like this one
Bluetooth#Bluetooth00:c2:c6:56:b0:61-00:15:be:0f:02:d7#RFCOMM:00000000:{00001101-0000-1000-8000-00805f9b34fb}
to remove everything past "#RFCOMM" and use the DeviceInformation.CreateFromIdAsync() function. This works but I was wondering if there was a cleaner solution to my problem since parsing a string can be a real problem if the string format change.
Is there a way to retrieve the name of the bluetooth device without having to ask to use all bluetooth device until we find it?
You can try with following code to get the name of the Bluetooth device:
var serviceInfoCollection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort), new string[] { "System.Devices.AepService.AepId" });
foreach (var serviceInfo in serviceInfoCollection)
{
var deviceInfo = await DeviceInformation.CreateFromIdAsync((string)serviceInfo.Properties["System.Devices.AepService.AepId"]);
System.Diagnostics.Debug.WriteLine($"Device name is: '{deviceInfo.Name}' and Id is: '{deviceInfo.Id}'");
}
The key point here is that Bluetooth device is one type of AssociationEndpoint objects. AEPs usually represent a device discovered over a wireless or network protocol. An AssociationEndpoint object is a child of a single AssociationEndpointContainer object and can contain 0 or more AssociationEndpointService objects. And RFComm service is one AssociationEndpointService that Bluetooth device contains. For more info, please see DeviceInformationKind enumeration and Enumerate devices over a network.
AssociationEndpointService has several properties. One of them is System.Devices.AepService.AepId which represents the identifier of the parent AssociationEndpoint object. So we can use this property to get the Bluetooth device information and once we get the device information, we can get the device name easily. However System.Devices.AepService.AepId property is not a commen property in DeviceInformation. So we need to use DeviceInformation.FindAllAsync(String, IIterable(String)) method to require this additional propertie. For more info, please see Device information properties.
So I have spent the whole night looking like a zombie in the morning trying to figure out how the OS handles an NFC tap for an NDEFLaunchApp Record and I have known the following.
I'm pretty sure that there is a workaround which lets you launch a system app / third party app (if you know the product Id / GUID) from your app. As there are apps in the Windows Phone Store which I have somehow figured out what I've been trying to.
I have come up with the following code:
NdefLaunchAppRecord appLaunchRecord = new NdefLaunchAppRecord();
appLaunchRecord.AddPlatformAppId("WindowsPhone", "{App GUID}");
appLaunchRecord.Arguments = "_default";
// Creating a new NdefMessage from the above record.
var message = new NdefMessage { appLaunchRecord };
// Getting the record from the message that we just created
foreach (NdefLaunchAppRecord record in message)
{
var specializedType = record.CheckSpecializedType(false);
if (specializedType == typeof(NdefLaunchAppRecord))
{
var x = String.Join(" ", record.Payload);
// Getting the payload by GetString gets a formatted Uri with args
string result = System.Text.Encoding.UTF8.GetString(record.Payload, 0, record.Payload.Length);
// result = "\0\fWindowsPhone&{5B04B775-356B-4AA0-AAF8-6491FFEA5630}\0\b_default";
// result = "(null)(form feed)WindowsPhone&{App GUID}(null)(backspace)_default
// So this will be sent to the OS and I believe the OS will then launch the specified app by an unknown protocol
// like xxx://result
// and the app will be launched?
// So is it then possible to somehow call the following:
await Windows.System.Launcher.LaunchUriAsync(new Uri("OUR MAGIC RESULT?", UriKind.RelativeOrAbsolute));
If anyone has / can figure out a way for this, it would be a REAL Service to the WP Community as developers are restricted by Microsoft to open certain settings / apps which are actually needed by those apps. For instance (speech settings, audio settings, about settings, alarms, region settings, date+time);
APPS that possibly have a workaround:
Music Hub Tile (Launches the old Music+Videos Hub)
http://www.windowsphone.com/en-gb/store/app/music-hub-tile/3faa2f9e-6b8d-440a-bb60-5dd76a5baec1
Tile for Bing Vision
http://www.windowsphone.com/en-gb/store/app/tile-for-bing-vision/05894022-e18c-40a4-a6cc-992383aa7ee8
There are reserved uri schemes for bing and zune.
See: http://msdn.microsoft.com/en-us/library/windows/apps/jj207065(v=vs.105).aspx
Those two apps propably use these and have found some undocumented use of the scheme.
If there is an uri scheme that launches any app by guid from within your app, it is hidden well.
Currently you can only launch apps that registered for an uri scheme or file association.
I am new to Windows 8 Store Apps, and need to fetch device ID in one of my XAML project. And this device ID should be unique. I searched the internet and came across 2 different ways.
First way in C# code,
private string GetHardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Second way in C# code,
var easClientDeviceInformation = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation()
GUID deviceId = easClientDeviceInformation.Id;
The first one gives in bits format whereas second one gives GUID. I am not getting any idea that which is correct one.
I referred this blog
And MSDN link too.
Can any one guide me regarding which can be used as Device ID?
I had same confusion, but finally used HardwareIdentification.GetPackageSpecificToken.
Because I find no information about uniqueness of EasClientDeviceInformation.ID
However, you can't use ID returned by HardwareIdentification.GetPackageSpecificToken as it is, because it depends upon many hardware components. And if any one of them changed, a different id will be returned.
There is more information at this link.
In VS2013, Microsoft uses the following method to retrieve the unique "installation id" or "device id" for the current device when uploading a channel URI retrieved from the Microsoft Push Notification Server (MPNS) to implement Push Notification:
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
string installationId = Windows.Security.Cryptography.CryptographicBuffer.EncodeToBase64String(token.Id);