[B4J] Windows users: let's test Windows OS hardware device_id ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All
Some unique ID of the Windows OS can be got basing on this lib.
Such sub is prepared:
B4X:
Sub Get_DeviceID As String
    Dim sb As StringBuilder
    sb.Initialize
 
    Dim sr As String = pdd.Get_MotherboardSN
    If sr <> Null And Not(sr.Contains("O.E.M")) Then sb.Append(sr)
    sr = pdd.Get_CPUID
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_MachineID
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_HddID1
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_HddID2
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_MacId
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_BiosVersion
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_CPUName
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_GpuID
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_MotherboardSN2
    If sr <> Null Then sb.Append(sr).Append("_")
    sr = pdd.Get_HWID1
    If sr <> Null Then sb.Append(sr)
 
    sr = sb.ToString
 
    If sr.As(String).Trim = "" Then
        sr = sr & GetEnvironmentVariable("computername","") & GetSystemProperty("user.name","")
    End If
    sr = sr.Replace(" ", "").Replace("\", "").Replace("/", "").Replace(":", "")
'    If sr.Length > 48 Then
'        sr = sr.SubString2(0, 48)
'    End If
 
    Return sr.ToLowerCase
End Sub

Who uses Windows OS - let's test this code, please ?
It seems, that not all Windows PC can get these unique IDs from the OS.

My PC result (admin user in Win10) is: phlwt048jbq0a1178bfbff00810f10_39444335-3130-4435-334e-e4e7494e37a4_504491340_s3t8na0kb02984_e49e794994e9379a4_hpqoem-1072009_amdryzen52500uwithradeonvegamobilegfx_84e7103c_phlwt048jbq0a1_b23bf05f51ae2c0f6a9a3d379b3b6ba0
1736495566211.png


So, it's OK, can be used for PC identification.

The project for compilation is attached (lib JUUID v.2.7 is here): if you have 5 mins, please, start and reply to this thread with your result - is it non-null ?
What is your Windows version and user type (admin) ?
 

Attachments

  • windows_device_id.zip
    3.2 KB · Views: 19
Last edited:

peacemaker

Expert
Licensed User
Longtime User
If to start on the same Win 10 PC under limited user (non-admin) - the result is PARTIALLY another (latest 10th part pdd.Get_HWID1 - is another !):

phlwt048jbq0a1178bfbff00810f10_39444335-3130-4435-334e-e4e7494e37a4_504491340_s3t8na0kb02984_e49e794994e9379a4_hpqoem-1072009_amdryzen52500uwithradeonvegamobilegfx_84e7103c_phlwt048jbq0a1_ed854182c72f6099cdc7c09b54ee7454

1736496311125.png
 

Daestrum

Expert
Licensed User
Longtime User
if it helps I get
bfebfbff000906a3_6a6b5a3a-8bf8-11ee-a4f5-bceca04273c4_-28849538_0000000000000001_0091595d9e19ba97e_lenovo-1_12thgenintel(r)core(tm)i5-12450h_3c9017aa_********_627d4cc7b1111a52e8db97e6c13035df

**edited to remove key for windows
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Yes, indeed. But for me most important that some computer can get non-usable ID, like @Cableguy informed me.
So, it's interesting to collect any statistics. How many such devices or Win versions that cannot give any unique ID.
If it's so - this way cannot be used universally to identify the user PCs.
 

peacemaker

Expert
Licensed User
Longtime User
Ahhh ! It seems, the new jUUID lib works much better, old one "Padina lib" returns "NA" for some calls.
 

Peter Simpson

Expert
Licensed User
Longtime User
Ahhh ! It seems, the new jUUID lib works much better, old one "Padina lib" returns "NA" for some calls.
I've been using this library with some long formulas and hidden files in multiple locations for registration purposes (registering my software). Actually, I used this library for about 3 years. This library reads the same IDs and my VS.Net solution, so I'm happy with that...
 

Peter Simpson

Expert
Licensed User
Longtime User
Which one ?
Oops, I should have been more clear and specific in my answer. The library that you already posted in your first post.

I use this library for reading hardware id and that is the basis for all my software serial numbers when registering. Well including two hardware IDs plus multiple formulas including my DOB + time, my partners DOB plus a few other formulas to boot, thus giving my software packages unique 12 digit serial numbers that I can then generate a unique unlock code for. This also matched VS.Net C# solution.

 

peacemaker

Expert
Licensed User
Longtime User
more clear and specific
Could you suggest more sharp what functions (Get...what ?) did you use practically ?
Now i have registered that some PC got "NA" id at app start and after several minutes - it's got OK non-null id.
 

Peter Simpson

Expert
Licensed User
Longtime User
Could you suggest more sharp what functions (Get...what ?) did you use practically ?
Now i have registered that some PC got "NA" id at app start and after several minutes - it's got OK non-null id.
From memory I believe that I use something like cpu1id or cpuid1 (I strip out all the letters leaving just the numbers, and also the hd1id. Please note that hd1 number can change if the customer formats the drive. That does not bother me as I store all my customers serial numbers and contact details, thus I can issue out a new/replacement unlock code for new serial numbers and I can block the old serial number at will if the customer is replacing or formatting a machine.

There no need to go as far as I've gone though, just issuing unlock codes is enough for most people. I had to go this far with blocking serial numbers because in the past I've had business owners try to run more copies of my retail software than they have paid for claiming that they scrapped their old machines. So me blocking apparent old serial numbers meant that customers can only run copies of my software that they have actually paid for, no more, no less.
 

Peter Simpson

Expert
Licensed User
Longtime User
Did you get short ID from the apps ? Like "NA" i received from one PC...
I don't believe that I've ever received an NA from hd1id (which is what I used to only use previous before adding cpu1id into my formula). I'm more than sure that I would have received one by now as I have a lot of customers using my business solutions.

Wait a minute, what function is giving you NA?
 

Peter Simpson

Expert
Licensed User
Longtime User
Get_MotherboardSN


I’ve not used MoardSN specifically because, back in my VS.Net C# days when I first wrote my registration/unlock software routines, I remember looking into using motherboard details. However, there weren’t enough numbers (or something similar) for me to use effectively. On the other hand, there were more than enough numbers (with letters removed) when using hd1id and gpuid. I’ve continued this practice from VS.Net to B4J without any issues whatsoever 🤞
 
Top