Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hard Drive Serial Number
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01675499
Message ID:
01675501
Views:
84
>>I tried to do a search for code to identify the hard drive serial number and I struck out.
>>So I did some research and came up with the below. I hope it helps someone
>>
>>Determine Drive Serial Number
>>objFSO = CreateObject('Scripting.FileSystemObject')
>>objDrive = objFSO.GetDrive('C:')
>>MESSAGEBOX(objDrive.SerialNumber)
>
>This gives me a negative value which is not right.

You need to convert it to hexadecimal:
LOCAL objFSO AS Scripting.FileSystemObject

objFSO = CreateObject('Scripting.FileSystemObject')
MESSAGEBOX("C: Serial Number: " + Str2hex(BINTOC(objFSO.GetDrive('C:').SerialNumber, "4RS"), 4))


FUNCTION Str2hex
LPARAMETERS tcStr, tnLen
LOCAL lnI, lnReturn

    lnReturn = 0
    FOR lnI = tnLen TO 1 STEP -1
        lnReturn = (lnReturn * 256) + ASC(SUBSTR(tcStr, lnI))
    NEXT
    RETURN STUFF(SUBSTR(TRANSFORM(lnReturn, "@0"), 3), 5, 0, "-")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform