>Thanks Hugo. This is very nice!
>
>But is WMI something that comes with the OS? If so, above what version? What does it take to install one if it doesn't exit?
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/system_requirements.asp>I also read from what Jos refered me to that some CPU doesn't support Serial #.
>HD info could be a good alternative for CPU one for what I am trying to achieve.
You can use WMI for this too, but only with XP or + (for this sample at least).
Here is a sample for getting the HD info, a little clumsy for I do not know a better way of just getting the object from the physical number:
function GetHDSerial(tnDevice)
local loLocator, lcUser, lcPassword, lcDomain, loNetWork, lnDevice
local loDrives, loDrive, lnCurrDevice, lcSerial
lnDevice = Iif(Vartype(tnDevice) = 'N', tnDevice, 0)
lcSerial = 'Unknown'
try
loWBEMLocator = createObject("wbemScripting.SwbemLocator")
loWMIService = loWBEMLocator.ConnectServer()
catch
loWMIService = null
endtry
if not Isnull(loWMIService)
loDrives = loWMIService.ExecQuery('Select SerialNumber from Win32_PhysicalMedia')
lnCurrDevice = 0
for each loDrive in loDrives
if lnCurrDevice = lnDevice
lcSerial = loDrive.SerialNumber
exit
endif
lnCurrDevice = lnCurrDevice + 1
endfor
endif
return Alltrim(lcSerial)
So, if you want the Serial of Disk 0:
? GetHDSerial(0)
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges