craigsboyd
IS-IT--Management
There have been a lot of questions regarding creating a hardware locking scheme using the CPU ID, MAC Address(es), and/or Volume Serial Number(s)...I realize that some of this has been laid out in FAQs and threads, but I thought I would start this thread to encompass all 3. Here is runnable code using Windows Script that will give you the information needed (cut-n-paste the code below into a prg and run it from within VFP):
BPeisch made a very good suggestion in a previous thread regarding this, and mentioned the SYS(2007) function. This can be used to allow you to give the user a serial number to use to unlock your application.
?SYS(2007, lcMyHardwareInfo)
Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
Code:
*!* Let's get the CPU ID
LOCAL lcComputerName, loWMI, lowmiWin32Objects, lowmiWin32Object
lcComputerName = GETWORDNUM(SYS(0),1)
loWMI = GETOBJECT("WinMgmts://" + lcComputerName)
lowmiWin32Objects = loWMI.InstancesOf("Win32_Processor")
FOR EACH lowmiWin32Object IN lowmiWin32Objects
WITH lowmiWin32Object
? "ProcessorId: " + TRANSFORM(.ProcessorId)
ENDWITH
ENDFOR
?
?
*!* Let's get the MAC Address(es)
LOCAL lcComputerName, loWMIService, loItems, loItem, lcMACAddress
lcComputerName = "."
loWMIService = GETOBJECT("winmgmts:\\" + lcComputerName + "\root\cimv2")
loItems = loWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
FOR EACH loItem IN loItems
lcMACAddress = loItem.MACAddress
IF !ISNULL(lcMACAddress)
? "MAC Address: " + loItem.MACAddress
?
ENDIF
ENDFOR
?
?
*!* Let's get the Volume Serial Number(s)
LOCAL lcComputerName, loWMIService, loItems, loItem, lcVolumeSerial
lcComputerName = "."
loWMIService = GETOBJECT("winmgmts:\\" + lcComputerName + "\root\cimv2")
loItems = loWMIService.ExecQuery("Select * from Win32_LogicalDisk")
FOR EACH loItem IN loItems
lcVolumeSerial = loItem.VolumeSerialNumber
IF !ISNULL(lcVolumeSerial)
? "Name: " + loItem.NAME
? "Volume Serial Number: " + loItem.VolumeSerialNumber
?
ENDIF
ENDFOR
BPeisch made a very good suggestion in a previous thread regarding this, and mentioned the SYS(2007) function. This can be used to allow you to give the user a serial number to use to unlock your application.
?SYS(2007, lcMyHardwareInfo)
Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon
[/sup]