Hello,
UUIDMBS.UUID return a random UUID (as UUIDMBS.randomUUID) on Mac and Windows, is this normal?
I would like to retrieve a unique identifier of the computer (mostly Windows) that I can compare each launch my software.
Greetings
olivier
Hello,
UUIDMBS.UUID return a random UUID (as UUIDMBS.randomUUID) on Mac and Windows, is this normal?
I would like to retrieve a unique identifier of the computer (mostly Windows) that I can compare each launch my software.
Greetings
olivier
UUID is meant to return a Universally Unique ID, so each time you call it, it will be different.
What you want is a hardware ID. There might be a plugin for this, but otherwise you can use things like the MAC address or computer serial number.
On the Mac, you can get any of this information through System Profiler, and I’ve included a System Profiler class in MacOSLib to make that easier. (Additional Modules -> KT’s Plist Stuff)
[quote=76007:@olivier vidal]Hello,
UUIDMBS.UUID return a random UUID (as UUIDMBS.randomUUID) on Mac and Windows, is this normal?
I would like to retrieve a unique identifier of the computer (mostly Windows) that I can compare each launch my software.
Greetings
olivier[/quote]
Yes, to be unique each time, that is what UUID’s are all about.
Check out module SystemInformationMBS, there you might be able to find what you are looking for.
http://www.monkeybreadsoftware.net/module-systeminformationmbs.shtml
Thank you Kem and Oliver!
actually, I’ll test SystemInformationMBS.MachineID
[quote=76020:@olivier vidal]Thank you Kem and Oliver!
actually, I’ll test SystemInformationMBS.MachineID :-)[/quote]
I believe to have read somewhere that MachineID is not reliable on Windows. Finding a reliable identifier has been repeatedly discussed on the forums and MBS mailing list. I’d suggest to do some research before just relying on it…
MachineID has now options to define what goes in.
Problem is that WMI sometimes report no HDD serial which gives another ID.
ok thank you Oliver and Christian.
in MBS doc:
if WMI report no HDD serial, the result is “A2254DEF74A74608D76D1BA49BD2E82A”?
Then, on Windows, it is always better to use the winProducKey flag?
I know it’s been answered but this method works for me. I get the machines SID.
[code]Function GetSID(strNTDomain as string, strNTAccount as string) As String
Soft Declare Function LookupAccountName Lib “advapi32.dll” Alias “LookupAccountNameA” _
(IpSystemName As cString, _
IpAccountName As cString, _
pSid As Ptr, _
ByRef cbSid As Integer, _
ReferencedDomainName As ptr, _
ByRef cbReferencedDomainName As Integer, _
ByRef peUse As Integer) As Integer
soft declare function ConvertSidToStringSid lib “advapi32.dll” alias “ConvertSidToStringSidA” _
(psid as Ptr, byref ssid as ptr) as boolean
Dim pSia As Integer
Dim pSiaByte As new MemoryBlock(5)
Dim pSid As new MemoryBlock(512)
dim thecbSid as Integer
dim thecbRDN as Integer
dim thepeUse as Integer = 1
Dim pDomain As new memoryblock(512)
Dim IReturn As Integer
IReturn = LookupAccountName(strNTDomain, strNTAccount,pSid, thecbSid, pDomain, thecbRDN, thepeUse)
pSid= new MemoryBlock(thecbSid)
pDomain= new MemoryBlock(thecbRDN)
IReturn = LookupAccountName(strNTDomain, strNTAccount,pSid, thecbSid, pDomain, thecbRDN, thepeUse)
dim sSid as Ptr
dim strSid as string
dim mb as MemoryBlock
call ConvertSidToStringSid(psid, ssid)
mb= ssid
Return mb.Cstring(0)
End Function
[/code]
You can call it with.
GetSid(“Machinename”,“MachineName”)
But Machine Name is not unique!?
With plugin you could use Windows Product ID for example which should be nearly unique. Maybe combine with CPU brand string.
On windows you can also use windows WMI classes with Xojo’s OLEObject class.
// This example will get the Windows operating system product serial identification number
// http://library.wmifun.net/cimv2/win32_operatingsystem.html
Dim locator, objWMIService, objs, objProperty As OLEOBJECT
Dim nobjs as Integer
// Connect to WMI
locator = new oleObject("WbemScripting.SWbemlocator", true)
Dim wmiServiceParams(2) as variant
wmiServiceParams(1) = "."
wmiServiceParams(2) = "root\\cimv2"
objWMIService= locator.invoke("ConnectServer", wmiServiceParams)
// Run the WMI query
objs = objWMIService.ExecQuery ("SELECT SerialNumber FROM Win32_OperatingSystem")
nobjs = objs.count - 1
For i as integer = 0 to nobjs
Dim stringData As String
objProperty = objs.ItemIndex(i)
// ItemIndex() is not supported in Windows XP only from Windows Vista and upwards
stringData = "Serial No: " + objProperty.Value("SerialNumber") + EndOfLine
msgbox stringData
Next
locator = Nil
exception err as oleexception
msgbox err.message
More examples how to use Windows WMI classes with OLEObject: