OVH Cloud OVH Cloud

Utilisation de api System_info

4 réponses
Avatar
Allem & Mickaël
Bonjour,

je manipule actuellement l'api SYSTEM_INFO pour récupérer des données de mon
cpu cependant je n'arrive pas à obtenir la description de mon processeur
(j'obtiens le type 586 et sa descritpion uniquement si c'est du pentium si
c'est de l'athlon cela ne marche pas)

Donc si qq'un pouvais m'aider

Merci

4 réponses

Avatar
Arnaud Debaene
Allem & Mickaël wrote:
Bonjour,


Bonjour.

je manipule actuellement l'api SYSTEM_INFO pour récupérer des données
de mon cpu cependant je n'arrive pas à obtenir la description de mon
processeur (j'obtiens le type 586 et sa descritpion uniquement si
c'est du pentium si c'est de l'athlon cela ne marche pas)



Ca veut dire *QUOI* ca ne marche pas? Tu obtiens quoi?

Arnaud
Avatar
Allem & Mickaël
J'obtient un numero à la place d'une descritpion :

OEMid : 0
Pagesize : 4096
Nb processeur : 1
Type processeur : 586 | 4199060

Voilaau lieu d'obtenir une descriptin j'obtiens 4199060

Voici mon code :


#include <windows.h>
#include <stdio.h>

typedef struct {
DWORD dwProcessorType ;
char* szProcessorType ;
} t_Processor ;


main () {

static t_Processor pType[] = {
PROCESSOR_INTEL_386, "Intel 386",
PROCESSOR_INTEL_486, "Intel 486",
PROCESSOR_INTEL_PENTIUM, "Intel Pentium",
PROCESSOR_MIPS_R4000, "Mips R4000",
PROCESSOR_ALPHA_21064, "Alpha 21064",
// PROCESSOR_PPC_601, "PPC 601",
// PROCESSOR_PPC_603, "PPC 603",
// PROCESSOR_PPC_604, "PPC 604",
// PROCESSOR_PPC_620, "PPC 620",
// PROCESSOR_HITACHI_SH3 "HITACHI SH3",
// PROCESSOR_HITACHI_SH3E "HITACHI SH3E",
// PROCESSOR_HITACHI_SH4 "HITACHI SH4",
// PROCESSOR_MOTOROLA_821 "MOTOROLA 821",
// PROCESSOR_SHx_SH3 "SHx SH3",
// PROCESSOR_SHx_SH4 "SHx SH4",
// PROCESSOR_STRONGARM "STRONGARM",
// PROCESSOR_ARM720 "ARM720",
// PROCESSOR_ARM820 "ARM820",
// PROCESSOR_ARM920 "ARM920",
// PROCESSOR_ARM_7TDMI "ARM 7TDMI",
0, NULL
} ;

unsigned int index = 0 ;

SYSTEM_INFO sysInfo ;
GetSystemInfo( &sysInfo ) ;

printf( "n %s : %d", TEXT("OEM ID : "), sysInfo.dwOemId );
printf( "n %s : %d", TEXT("Page Size : "),
sysInfo.dwPageSize );
printf( "n %s : %d", TEXT("SystemInfo : "),
sysInfo.dwProcessorType);
printf( "n %s : %d", TEXT("Nombre de processeur : "),
sysInfo.dwNumberOfProcessors);
printf( "n %s : %d", TEXT("Nombre de processeur : "),
sysInfo.wProcessorArchitecture);

while( pType[index].szProcessorType != NULL ) {
if( sysInfo.dwProcessorType == pType[index].dwProcessorType ) {
printf( "n %s : %d", TEXT("Type de Processeur : "),
pType[index].dwProcessorType);
printf( "%s %d", TEXT(" | "), pType[index].szProcessorType);
break ;
}
index++ ;
}
if( pType[index].szProcessorType == NULL )
printf( "n %s", TEXT("Unknown type."),
pType[index].szProcessorType);

getchar();
}


"Allem & Mickaël" a écrit dans le message de news:
4038291d$0$28110$
Bonjour,

je manipule actuellement l'api SYSTEM_INFO pour récupérer des données de


mon
cpu cependant je n'arrive pas à obtenir la description de mon processeur
(j'obtiens le type 586 et sa descritpion uniquement si c'est du pentium si
c'est de l'athlon cela ne marche pas)

Donc si qq'un pouvais m'aider

Merci






Avatar
Arnaud Debaene
Allem & Mickaël wrote:
<snip>

while( pType[index].szProcessorType != NULL ) {
if( sysInfo.dwProcessorType == pType[index].dwProcessorType )



Extrait de la doc MSDN sur SYSTEM_INFO :
dwProcessorType : An obsolete member that is retained for compatibility with
Windows NT 3.5 and earlier. Use the wProcessorArchitecture, wProcessorLevel,
and wProcessorRevision members to determine the type of processor.


{ printf( "n %s : %d", TEXT("Type de Processeur : "),
pType[index].dwProcessorType);
printf( "%s %d", TEXT(" | "),
pType[index].szProcessorType); break ;



szProcessorType est un const char*, donc le formattage de printf c'est %s,
pas %d :
printf( "%s %s", TEXT(" | "), pType[index].szProcessorType);

Ce que tu affiches pour l'instant, c'est l'adresse de la chaine "Intel
Pentium", et pas la chaine elle-même.

Arnaud
Avatar
Christian ASTOR
Allem & Mickaël a écrit:

je manipule actuellement l'api SYSTEM_INFO pour récupérer des données de mon
cpu cependant je n'arrive pas à obtenir la description de mon processeur
(j'obtiens le type 586 et sa descritpion uniquement si c'est du pentium si
c'est de l'athlon cela ne marche pas)



Il y a déjà eu un thread à ce sujet il y a quelques jours...
Donc, soit WMI si installé (simple), soit CPUID : ex détaillé =>
http://src.fitkursk.ru/articles/cpudetect.zip)
ou, en simplifié =>
(cf docs pour chaque fabriquant, ex AMD :
"AMD Processor Recognition Application Note")

{
static int nVendorIDString[12];
char sBuffer[255];
int nReturn;
static int nNameString[48];

__try
{
__asm
{
mov eax,0
cpuid
mov nVendorIDString[0],ebx
mov nVendorIDString[4],edx
mov nVendorIDString[8],ecx
}
}
__except (1)
{
return (-1);
}

_asm
{
mov eax, 1
cpuid
mov nReturn, eax
}

int nFamily = nReturn >> 8;
int nModel = (nReturn >> 4) & 0x0F;
int nStepping = nReturn & 0x0F;

__asm
{
mov eax, 80000002h
cpuid
mov nNameString[0],eax
mov nNameString[4],ebx
mov nNameString[8],ecx
mov nNameString[12],edx
mov eax, 80000003h
cpuid
mov nNameString[16],eax
mov nNameString[20],ebx
mov nNameString[24],ecx
mov nNameString[28],edx
mov eax, 80000004h
cpuid
mov nNameString[32],eax
mov nNameString[36],ebx
mov nNameString[40],ecx
mov nNameString[44],edx
}

wsprintf (sBuffer, "Vendor String : %snFamily : %dnModel :
%dnStepping : %dnProcessor Name : %s",
(LPCSTR)nVendorIDString, nFamily, nModel, nStepping, (LPCSTR)nNameString);
MessageBox(NULL, sBuffer, "Info", MB_OK);
}