RE:Serial Number Hard Disk
te envio algunas funciones para obtener y convertir los diferentes valores que obtengas del serial
Dimension aKnownDrives[1]
lnDrives = GetDriveStrings(@aKnownDrives)
If lnDrives > 0
Dimension aDriveInfo[3]
For ix = 1 to lnDrives
=GetVolInfo( aKnownDrives[ix], @aDriveInfo )
? "Drive : [" ;
+ aKnownDrives[ix] ;
+ "] Type : [" ;
+ cDriveType(aKnownDrives[ix]) ;
+ "] Volume Name : [" ;
+ aDriveInfo[1] ;
+ "] Sytem : [" ;
+ aDriveInfo[2] ;
+ "] Serial No : [" ;
+ aDriveInfo[3] +"]"
Endfor
Endif
Function cDriveType
Lparameters tcRoot && Root of drive ie: "c:"
Local array aDrvTypes[7]
aDrvTypes[1]="CANNOT_DETERMINE"
aDrvTypes[2]="INVALID_DRIVE"
aDrvTypes[3]="DRIVE_REMOVABLE"
aDrvTypes[4]="DRIVE_FIXED"
aDrvTypes[5]="DRIVE_REMOTE"
aDrvTypes[6]="DRIVE_CDROM"
aDrvTypes[7]="DRIVE_RAMDISK"
Return aDrvTypes[nDriveType(tcRoot)+1]
Function nDriveType
Lparameters tcRoot && Root of drive ie: "c:"
Declare integer GetDriveType in WIN32API string @cDrvLetter
Return GetDriveType(@tcRoot)
Function GetVolInfo
Lparameters lcRoot, taInfo && Root of drive ie: "c:", InfoArray passed by ref
Declare SHORT GetVolumeInformation IN Win32API;
STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
INTEGER nVolumeNameSize, INTEGER @lpVolumeSerialNumber,;
INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize
Store 0 TO lnserialno, lncomplen, lnsysflags
Store SPACE(260) TO lcvolname, lcsysname
Store LEN(lcvolname) TO lnvolsize, lnnamesize
If (GetVolumeInformation(@lcRoot, @lcvolname,;
lnvolsize, @lnserialno, @lncomplen, @lnsysflags,;
@lcsysname, lnnamesize) # 0)
Dimension taInfo[3]
taInfo[1] = substr(lcvolname, 1, at(chr(0),lcvolname)-1) && Volume name
taInfo[2] = substr(lcsysname, 1, at(chr(0),lcsysname)-1) && System
taInfo[3] = dec2hex(lnserialno) && Serial in hex format
Else
taInfo = ""
Endif
Return
Function GetDriveStrings
Parameters aDriveStrings && Array passed by ref
Local lpBuffer, nBufferLength, lnBuflen, lnDriveCount, ix
Declare integer GetLogicalDriveStrings in Win32API ;
integer nBufferLength, string @ lpBuffer
lpBuffer = space(26*128)
nBufferLength = 26*128
lnBuflen = GetLogicalDriveStrings(nBufferLength, @lpBuffer)
If lnBuflen # 0 && Succeeded
lpBuffer = left(lpBuffer,lnBuflen)
lnDriveCount = occurs(chr(0),lpBuffer)
Dimension aDriveStrings[lnDriveCount]
For ix = 1 to lnDriveCount
aDriveStrings[ix] = ;
substr(lpBuffer, ;
iif( ix=1,1,at(chr(0),lpBuffer,ix-1)+1 ), ;
at(chr(0),lpBuffer,ix) ;
- iif( ix=1,0,at(chr(0),lpBuffer,ix-1)) - 1)
Endfor
Else
lnDriveCount = 0
Endif
Return lnDriveCount
Function dec2hex
Parameter nDecimal, nDigits
** Converts from base 10 to base 16. Returns Hex notation in a string whose length
** is always a multiple of 2, unless the nDigits parameter is specified to pad the
** string with zeroes.
cHex = ""
Do WHILE nDecimal >= 16
cHex = hexdigit(nDecimal % 16) + cHex
nDecimal = int(nDecimal/16)
Enddo
cHex = hexdigit(nDecimal) + cHex
Return PADL(cHex, ;
iif( PARAMETERS() < 2, ;
ceiling(len(cHex)/2)*2, nDigits ), "0")
Function hexdigit
Parameters nDecimal
Return iif(nDecimal>9,chr(asc("A")+nDecimal%10),str(nDecimal,1))
Suerte