B4J Library (b4j)[juuid] Get Unique hardware ID

Get Unique hardware ID in b4j
tested on windows only you can test on mac or linux

8 method to get Unique hardware id

b4j.png




updated v1.8
fixed error in none_ui apps
removed all unnecessary methods
two new method added
Get_HWID1
Get_HWID2

updated v2.0
Using java standard functions without modification
Changed Lib Name to juuid (jpadina deprecated)
added Get_MachineID2
added Email Validation

updated v2.1
added Get_HddId3

updated v2.2
added Get_HddID4(String Driveletter)

updated v2.3
added Get_LocalHardisk_Info

updated v2.4
Added :
Get_CPUID2
Get_CPUName
Get_TotalPhysicalMemory
Get_MotherBoardName
Get_AllMacIds
Get_GpuName
Get_GpuID
Get_RandomUuid


How Use :
B4X:
    Dim pdd As jUUID

    Log(pdd.Get_CPUID )
    Log( pdd.Get_HddID1 )
    Log( pdd.Get_HddID2 )
    Log( pdd.Get_HddID3 )
    Log( pdd.Get_HddID4("C") )  //Hard drive letter
    Log ( pdd.Get_MachineID )
    Log ( pdd.Get_MachineID2 )
    Log ( pdd.Get_MacId )
    Log ( pdd.Get_MotherboardSN )
    Log( pdd.Get_HWID1 )  'hardware + software > can change with changing windows or user
    Log( pdd.Get_HWID2 )  'hardware + software > can change with changing windows or user

    Dim l As List = p.Get_LocalHardisk_Info
    For i=1 To l.Size-1
    
        Log(l.Get(i))

    Next


B4X:
Sub GetUid As String
 
   Dim pdd As jUUID
    Dim sr As String=pdd.Get_MotherboardSN
    If sr<>Null  Then
        sr=pdd.Get_MotherboardSN
 
    Else If pdd.Get_CPUID<>Null Then
        sr = pdd.Get_CPUID
 
    Else If pdd.Get_MachineID<>Null Then
        sr=pdd.Get_MachineID
 
     Else If pdd.Get_MachineID2<>Null Then
        sr=pdd.Get_MachineID2

    Else If pdd.Get_HddID1<>Null Then
        sr=pdd.Get_HddID1
 
    Else If pdd.Get_HddID2<>Null Then
        sr=pdd.Get_HddID2
 
    Else If pdd.Get_MacId<>Null Then
        sr=pdd.Get_MacId
 
    End If
 
   Return sr

End Sub


Any function that has no result returns a null value
lib (jar and xml files) atteched.
 

Attachments

  • Juuid 2.4.zip
    7.9 KB · Views: 175
Last edited:

B4XDev

Member
Licensed User
...if it is Windows, you can do it alone... with just a "cmd" command...

this will return all serial numbers of drives... (ofcourse there is the old command, vol c:, vol d: )
B4X:
wmic diskdrive get serialnumber

Those are some weird numbers I've not seen before. What format is the serial number?! Is that an immutable ID?
 

B4XDev

Member
Licensed User
Number allocated by the manufacturer to identify the physical media.

Example: WD-WM3493798728

Wow! Is it a unique ID and immutable? It won't change with software updates (like, to the OS) or a reformat?
 

Magma

Expert
Licensed User
Longtime User

B4XDev

Member
Licensed User
i think that not change... "not sure" ... but as search it is totally different from "vol"...

And I cannot tell or get information specifically for a particular drive letter (C, D, etc.). Do you know how to match the drive info from wmic with the drive letter?
 

B4XDev

Member
Licensed User
a little different... not C: or D:... more physical... but if you search you find the way...
B4X:
wmic diskdrive get Name, SerialNumber

I've tried a couple of options (deviceid, serialnumber, systemname, etc...) but none of them return the drive letter that has been assigned to the drive. I will see what I can find searching the interwebs...
 

Magma

Expert
Licensed User
Longtime User
this return the logicaldisks - may be the row-series is the same... not checked... (also you can see the different serial number here)
B4X:
wmic logicaldisk get caption,description,drivetype,providername,volumename,volumeserialnumber
 

behnam_tr

Active Member
Licensed User
Yes! Perfect.

One more thing... PCs can have multiple drives. Is there a way we can specify which drive we want to get the serial number of?

Like
B4X:
Sub Get_HddId(myDriveLetter As String) As String

B4X:
Log(Get_HddId("C"))
'or
Log(Get_HddId("C:"))
'or
Log(Get_HddId("C:\"))

One of those... ๐Ÿ˜

added !!
Log(Get_HddId4("C"))
download v2.2
 
Last edited:

B4XDev

Member
Licensed User
sorry... this can't be..right i said... because physical drives... can have... more than 1 partition with other names..... so.... can't think something for that... for now..

It's working perfectly! Thank you!
 

behnam_tr

Active Member
Licensed User
this return the logicaldisks - may be the row-series is the same... not checked... (also you can see the different serial number here)
B4X:
wmic logicaldisk get caption,description,drivetype,providername,volumename,volumeserialnumber

thanks for code
i added to lib (v2.3)


B4X:
Dim l As List = p.Get_LocalHardisk_Info
    For i=1 To l.Size-1
        
        Log(l.Get(i))

    Next
 
Top