function main()
? GetCpuIDHarbour()
return nil
FUNCTION GetCpuIDHarbour()
LOCAL nHandle
LOCAL cCommand := "wmic cpu get ProcessorId"
LOCAL aLines
LOCAL cID
local cLine
local nRet
local cStdOut := space(40)
local cStdErr := space(40)
nRet = hb_processRun( cCommand, , @cStdOut, @cStdErr )
IF Empty( cStdOut )
RETURN ""
ENDIF
// Procesar la salida. wmic suele devolver una cabecera y el valor.
// Ejemplo de salida:
// ProcessorId
// BFEBFBFF00040671
// Dividir el resultado por líneas
aLines := hb_aTokens( cStdOut, Chr(13) + Chr(10) )
// La segunda línea (índice 2, si la cabecera es la 1ra y no hay líneas vacías)
// debería contener el ID. Necesitarás limpiar espacios y saltos de línea.
IF Len( aLines ) >= 2
// El ID suele estar en la segunda línea después de limpiar espacios.
cID := AllTrim( aLines[ 2 ] )
// Buscar la línea que no es 'ProcessorId' y no está vacía
FOR EACH cLine IN aLines
cLine := AllTrim( cLine )
IF ! Empty( cLine ) .AND. Upper( cLine ) <> "PROCESSORID"
RETURN cLine // Este es el ProcessorId
ENDIF
NEXT
ENDIF
RETURN ""
Function WMainInfo()
LOCAL oDatos, oSrv, oJob, i
LOCAL nFree:= ""
LOCAL oLoc:= CreateObject( "wbemScripting.SwbemLocator" )
LOCAL objWMI:= oLoc:ConnectServer()
LOCAL oSistema:= objWMI:ExecQuery("Select * from Win32_PhysicalMedia")
LOCAL oDisco:= objWMI:ExecQuery("Select * from Win32_LogicalDisk")
LOCAL oParti:= objWMI:ExecQuery("Select * from CIM_DiskPartition")
LOCAL oDisket:= objWMI:ExecQuery("Select * From Win32_LogicalDisk Where DeviceID = 'A:'")
LOCAL objUnd:= objWMI:ExecQuery("Select * from Win32_MappedLogicalDisk")
LOCAL oUnd:= objWMI:ExecQuery("Select * from Win32_CDROMDrive")
LOCAL oResolu:= objWMI:ExecQuery("Select * from Win32_DesktopMonitor")
LOCAL oSistem:= objWMI:ExecQuery("Select * from Win32_OperatingSystem")
LOCAL oUsers:= objWMI:ExecQuery("Select * from Win32_Account")
LOCAL oServ:= objWMI:ExecQuery("Select * from Win32_Service Where Name = 'Themes'")
LOCAL oTime:= objWMI:ExecQuery("Select * from Win32_LocalTime")
LOCAL oProc:= objWMI:ExecQuery("Select * from Win32_Processor")
LOCAL oJbs:= objWMI:ExecQuery("SELECT Product, SerialNumber FROM Win32_BaseBoard")
LOCAL oIpSet:= objWMI:ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
LOCAL oList := objWMI:ExecQuery("Select * from Win32_ComputerSystem")
//Return(Nil)
objWMI:= oLoc:ConnectServer()
oJbs := objWMI:ExecQuery( "select * from Win32_BaseBoard" )
//oSrv:ExecQuery( "SELECT * FROM Win32_BaseBoard" )
FOR EACH oDatos IN oJbs
oApp:tMBrd := Alltrim(cValtoChar(oDatos:Product))
oApp:sMBrd := Alltrim(cValtoChar(oDatos:SerialNumber))
NEXT
FOR EACH oDatos IN oProc
oApp:nCpu := Alltrim(cValtoChar(oDatos:Name))
oApp:vCpu := Alltrim(cValtoChar(oDatos:CurrentClockSpeed)) + " Mghz"
oApp:iCpu := Alltrim(cValtoChar(oDatos:ProcessorID)) // aqui esta el ID
NEXT
FOR Each oDatos in oSistem
oApp:vDOS := oDatos:Caption + " " + oDatos:VERSION
NEXT
Return(NIl)
Follow the steps below using the search bar in Windows*, located on the bottom of the screen.
Type wmic
Choose the application called wmic
Type cpu get processorid
The last five digits of the number are displayed to represent the CPUID for the processor.