Trying to get unique device info from C#

Hello there! I have been trying to get a unique user device id using the code below:

ArrayList hardDriveDetails = new ArrayList();

class HardDrive
{
private string model = null;
private string type = null;
private string serialNo = null;
public string Model
{
get { return model; }
set { model = value; }
}
public string Type
{
get { return type; }
set { type = value; }
}
public string SerialNo
{
get { return serialNo; }
set { serialNo = value; }
}
}

public string GetDeviceUniqueIdentifier() {
ManagementObjectSearcher moSearcher = new ManagementObjectSearcher(“SELECT * FROM Win32_DiskDrive”);
string user_device_id = “”;
foreach (ManagementObject wmi_HD in moSearcher.Get())
{
HardDrive hd = new HardDrive(); //User Defined Class
hd.Model = wmi_HD[“Model”].ToString(); //Model Number
hd.Type = wmi_HD[“InterfaceType”].ToString(); //Interface Type
hd.SerialNo = wmi_HD[“SerialNumber”].ToString(); //Serial Number
hardDriveDetails.Add(hd);
user_device_id += (hd.Model + " | " + hd.Type + " | " + hd.SerialNo);
}
return user_device_id;
}

But I get the following error in Unity:

Assets\Scripts\RegisterUser.cs(6,14): error CS0234: The type or namespace name ‘Management’ does not exist in the namespace ‘System’ (are you missing an assembly reference?)

I tried to creatre a folder called Plugins and added a System.Management.dll file into it as was advised after google search. Also I tried to add a reference through Visual Studio C#, but in vain. I heard that option is kind of not supported is Mono. Is this true? How can I get user device info? I need it for unregisitred users to take into account their progress. Is there any other way to track it except using registration? Something like cookie in the web?

Finally I was able to solve the problem using SystemInfo.deviceUniqueIdentifier. It returns that diffrently for each particular device. Thank you to all who was trying to help me and had spent their time.

1 Like

Who? Anyway, this is interesting https://discussions.unity.com/t/744120 Have you considered just using PlayerPrefs to track user progress? When you publish to the stores, you will need to tell them you are collecting this info. I believe it’s PII in California, for example (but I’m not a lawyer).