Modify

Ticket #9 (closed idea: fixed)

Opened 4 years ago

Last modified 3 years ago

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

comment:1 Changed 3 years ago by thaeron

  • Milestone set to Version 1.7

comment:2 Changed 3 years ago by thaeron

  • Status changed from new to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.