Page 1 of 1
nee the cpu Id
Posted: Sat Nov 08, 2025 1:30 pm
by Silvio.Falconi
I found this but not run
Code: Select all | Expand
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( GETCPUID )
{
unsigned int eax = 1, ebx = 0, ecx = 0, edx = 0;
__asm {
mov eax, 1
cpuid
mov ebx, ebx
mov edx, edx
}
char szID[17];
wsprintfA( szID, "%08X%08X", ebx, edx );
hb_retc( szID );
}
#pragma ENDDUMP
Re: nee the cpu Id
Posted: Sat Nov 08, 2025 1:38 pm
by Silvio.Falconi
correct because BCC7 does not support __asm { ... } with local variables
Code: Select all | Expand
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( GETCPUID )
{
char szID[17];
unsigned long ebx, edx;
// Usa __asm con sintassi BCC7
_asm {
mov eax, 1
cpuid
mov ebx, ebx
mov edx, edx
}
// Usa variabili locali per ebx, edx
_asm mov ebx, ebx
_asm mov edx, edx
// Formatta come stringa
wsprintfA( szID, "%08lX%08lX", ebx, edx );
hb_retc( szID );
}
#pragma ENDDUMP
Re: nee the cpu Id
Posted: Sun Nov 09, 2025 3:11 am
by wilsongamboa
Silvio good night maybe this ( only windows )
Code: Select all | Expand
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 ""
Re: nee the cpu Id
Posted: Thu Nov 20, 2025 5:28 pm
by Willi Quintana
HI,,,
Code: Select all | Expand
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)
Re: nee the cpu Id
Posted: Thu Nov 20, 2025 5:36 pm
by Willi Quintana
From CMD
Code: Select all | Expand
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.