MSciglio
24-06-2002, 19:51
Salve a tutti.
Ho la necessità di ottenere un codice univoco per il pc. Quale posso utilizzare? Ho pensato al codice della CPU ma non so come ottenerlo utilizzando C++. Un'altra possibilità potrebbe essere quella di utilizzare l'indirizzo MAC della scheda di rete ma questo funzionerebbe solo se il pc ne possiede una.
Cosa mi consigliate?
Grazie
L'ID del processore non lo puoi ottenere...anche perchè negli AMD non esiste, mentre negli Intel è spesso disabilitato...
Puoi usare diverse informazioni per creare il tuo sistema di sicurezza :
1) Il codice che identifica il tipo di CPU
2) Il seriale del sistema operativo
3) Il nome della macchina
1) Prova a dare un'cchiata a questo codice :
int signature = 0; //CPU signature variable
int stepping_id = 0; //CPU stepping id variable
int model = 0; //CPU model variable
int inst_family = 0; //CPU instruction fammily variable
unsigned int reg_ax = 0 ; //AX register
unsigned long reg_eax,reg_edx, test_reg; //EAX, EDX, and test register variables
unsigned long print_eax,print_ebx,print_ecx,print_edx; //Display variable
int maxbit = 18; //Control loop variable
int bits ;
//il codice per ottenre il CPUID è in pratica solo questo inline asm sotto
asm {
mov EAX,1 //EAX = 1 or function 1
db 0x0F, 0xA2 //CPUID opcode
}
reg_edx = _EDX; //store the standard feature flags
reg_ax = _AX;
asm mov BX, reg_ax
asm and BL,0x0F //mask the right most 4 bits
stepping_id = _BL; //to get the cpu stepping id
asm mov BX, reg_ax
asm and BL,0xF0 //mask the left most 4 bits
asm ror BL,4 //to get the cpu model
model = _BL;
asm mov BX, reg_ax //get the cpu instruction family
asm and BH, 0x0F
inst_family = _BH;
asm and EAX,0xFFFFF000 //get the bits[31-12]
asm ror EAX,12
reg_eax = _EAX;
asm mov BX, reg_ax //get the cpu signature
asm and BX,0x0FF0
signature = _BX;
2) Lo vai a prendere nel registro in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
In ProductId trovi il seriale del sistema operativo..
3) Con l'API GetComputerName
MSciglio
25-06-2002, 14:24
Grazie mille! Sei stato di immenso aiuto :)
Bye
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.