Wiki Home

Retrieving Hardware Information


Namespace: VFP
One way to retrieve this information is to use windows scripting...

*!* Let's get the Free Physical Memory of local machine in KB
LOCAL loWMIService, loItems, loItem
loWMIService = GETOBJECT("winmgmts:\\.")
loItems = loWMIService.ExecQuery("Select * from Win32_OperatingSystem")
FOR EACH loItem IN loItems
   ? int(val(loItem.FreePhysicalMemory))
ENDFOR
-- David Fung

*!* 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
-- CraigSBoyd ---- CategoryCodeSamples
( Topic last updated: 2005.02.14 06:33:25 AM )