Hi,
I am searching for a solution for registration problem.
I found your code in one of the thread.
Thanks for giving the solution.
OS in my machine is Win Xp and It is working fine. but on a machine having OS Win 98, it is returning 'Unknow' and not the HD Serial Number.
Can you please tell me if it will also work for other OS like Win 98 and Win 2000? If not, then which API can be used for that.
Thanks in Advance.
Regards,
Somesh
>>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)