Modify ↓
Ticket #9 (closed idea: fixed)
idee détection cpu sous windoz
| Reported by: | thaeron | Owned by: | thaeron |
|---|---|---|---|
| Priority: | minor | Milestone: | Version 1.7 |
| Component: | kernel | Version: | |
| Keywords: | Cc: |
Description
Se baser sur le code d'xchat pour la détection de la version de windoz ainsi que du cpu :
/* code issu d'xchat pour avoir les infos sur le système
exemples :
Windows 6.0 [i1586/1,90GHz]
Windows 5.1 [i1586/3,01GHz]
*/
#ifdef WIN32
static int
get_mhz (void)
{
HKEY hKey;
int result, data, dataSize;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Hardware\\Description\\System\\"
"CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
dataSize = sizeof (data);
result = RegQueryValueEx (hKey, "~MHz", 0, 0, (LPBYTE)&data, &dataSize);
RegCloseKey (hKey);
if (result == ERROR_SUCCESS)
return data;
}
return 0; /* fails on Win9x */
}
char *
get_cpu_str (void)
{
static char verbuf[64];
OSVERSIONINFO osvi;
SYSTEM_INFO si;
double mhz;
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
GetVersionEx (&osvi);
GetSystemInfo (&si);
mhz = get_mhz ();
if (mhz)
{
double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz;
const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz";
sprintf (verbuf, "Windows %ld.%ld [i%d86/%.2f%s]",
osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel,
cpuspeed, cpuspeedstr);
} else
sprintf (verbuf, "Windows %ld.%ld [i%d86]",
osvi.dwMajorVersion, osvi.dwMinorVersion, si.wProcessorLevel);
return verbuf;
}
#else
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](http://cryptofractalx.ath.cx/imgs/ns-logo-complet.png)