Click here to Skip to main content
15,893,381 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CAsyncSocket::Close Crashes Pin
includeh1012-Aug-09 7:50
includeh1012-Aug-09 7:50 
GeneralRe: CAsyncSocket::Close Crashes Pin
staticv12-Aug-09 19:59
staticv12-Aug-09 19:59 
AnswerRe: CAsyncSocket::Close Crashes Pin
Moak13-Aug-09 13:30
Moak13-Aug-09 13:30 
GeneralRe: CAsyncSocket::Close Crashes Pin
staticv13-Aug-09 19:55
staticv13-Aug-09 19:55 
GeneralRe: CAsyncSocket::Close Crashes Pin
Moak13-Aug-09 21:44
Moak13-Aug-09 21:44 
GeneralRe: CAsyncSocket::Close Crashes Pin
staticv14-Aug-09 5:12
staticv14-Aug-09 5:12 
QuestionHow get the CPU information ? Pin
bzsolt9112-Aug-09 2:11
bzsolt9112-Aug-09 2:11 
AnswerRe: How get the CPU information ? Pin
Garth J Lancaster12-Aug-09 2:28
professionalGarth J Lancaster12-Aug-09 2:28 
this gives you some of the info - not sure if speed is in there ...

http://msdn.microsoft.com/en-us/library/hskdteyh(VS.80).aspx[^]

[edit]
this from gamedev shows some interesting things - Ive seen the same method for getting the speed used before ...

#include <windows.h>
#include <intrin.h>

//============================================================================
// Read the CPU speed from the registry
//============================================================================
DWORD ReadCPUSpeedFromRegistry(DWORD dwCPU)
{
HKEY hKey;
DWORD dwSpeed;

	// Get the key name
	wchar_t szKey[256];
	_snwprintf(szKey, sizeof(szKey)/sizeof(wchar_t),
		L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d\\", dwCPU);

	// Open the key
	if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
	{
		return 0;
	}

	// Read the value
	DWORD dwLen = 4;
	if(RegQueryValueEx(hKey, L"~MHz", NULL, NULL, (LPBYTE)&dwSpeed, &dwLen) != ERROR_SUCCESS)
	{
		RegCloseKey(hKey);
		return 0;
	}

	// Cleanup and return
	RegCloseKey(hKey);
    return dwSpeed;
}

//============================================================================
// Calculate and log the CPU speed and features
//============================================================================
void LogCPU()
{
unsigned nHighestFeature;
unsigned nHighestFeatureEx;
int nBuff[4];
char szMan[13];
char szFeatures[256];
unsigned nProcessorType;

	// Get CPU manufacturer and highest CPUID
	__cpuid(nBuff, 0);
	nHighestFeature = (unsigned)nBuff[0];
	*(int*)&szMan[0] = nBuff[1];
	*(int*)&szMan[4] = nBuff[3];
	*(int*)&szMan[8] = nBuff[2];
	szMan[12] = 0;
	if(strcmp(szMan, "AuthenticAMD") == 0)
		nProcessorType = PROCESSOR_AMD;
	else if(strcmp(szMan, "GenuineIntel") == 0)
		nProcessorType = PROCESSOR_INTEL;
	else
		nProcessorType = PROCESSOR_UNKNOWN;

	// Get highest extended feature
	__cpuid(nBuff, 0x80000000);
	nHighestFeatureEx = (unsigned)nBuff[0];

	// Get processor brand name
	if(nHighestFeatureEx >= 0x80000004)
	{
		char szCPUName[49];
		szCPUName[0] = 0;
		__cpuid((int*)&szCPUName[0], 0x80000002);
		__cpuid((int*)&szCPUName[16], 0x80000003);
		__cpuid((int*)&szCPUName[32], 0x80000004);
		szCPUName[48] = 0;
		for(int i=(int)strlen(szCPUName)-1; i>=0; --i)
		{
			if(szCPUName[i] == ' ')
				szCPUName[i] = '\0';
			else
				break;
		}

		ELog::Get().SystemFormat(L"PERF    : CPU: %S (%S)\n", szCPUName, szMan);
	}
	else
		ELog::Get().SystemFormat(L"PERF    : CPU: %S\n", szMan);

	// Get CPU features
	szFeatures[0] = 0;
	if(nHighestFeature >= 1)
	{
		__cpuid(nBuff, 1);
		if(nBuff[3] & 1<<0)
			strcat(szFeatures, "FPU ");
		if(nBuff[3] & 1<<23)
			strcat(szFeatures, "MMX ");
		if(nBuff[3] & 1<<25)
			strcat(szFeatures, "SSE ");
		if(nBuff[3] & 1<<26)
			strcat(szFeatures, "SSE2 ");
		if(nBuff[2] & 1<<0)
			strcat(szFeatures, "SSE3 ");

		// Intel specific:
		if(nProcessorType == PROCESSOR_INTEL)
		{
			if(nBuff[2] & 1<<9)
				strcat(szFeatures, "SSSE3 ");
			if(nBuff[2] & 1<<7)
				strcat(szFeatures, "EST ");
		}

		if(nBuff[3] & 1<<28)
			strcat(szFeatures, "HTT ");
	}

	// AMD specific:
	if(nProcessorType == PROCESSOR_AMD)
	{
		// Get extended features
		__cpuid(nBuff, 0x80000000);
		if(nHighestFeatureEx >= 0x80000001)
		{
			__cpuid(nBuff, 0x80000001);
			if(nBuff[3] & 1<<31)
				strcat(szFeatures, "3DNow! ");
			if(nBuff[3] & 1<<30)
				strcat(szFeatures, "Ex3DNow! ");
			if(nBuff[3] & 1<<22)
				strcat(szFeatures, "MmxExt ");
		}

		// Get level 1 cache size
		if(nHighestFeatureEx >= 0x80000005)
		{
			__cpuid(nBuff, 0x80000005);
			ELog::Get().SystemFormat(L"PERF    : L1 cache size: %dK\n", ((unsigned)nBuff[2])>>24);
		}
	}

	// Get cache size
	if(nHighestFeatureEx >= 0x80000006)
	{
		__cpuid(nBuff, 0x80000006);
		ELog::Get().SystemFormat(L"PERF    : L2 cache size: %dK\n", ((unsigned)nBuff[2])>>16);
	}

	// Log features
	ELog::Get().SystemFormat(L"PERF    : CPU Features: %S\n", szFeatures);

	// Get misc system info
	SYSTEM_INFO theInfo;
	GetSystemInfo(&theInfo);

	// Log number of CPUs and speeds
	ELog::Get().SystemFormat(L"PERF    : Number of CPUs: %d\n", theInfo.dwNumberOfProcessors);
	for(DWORD i=0; i<theInfo.dwNumberOfProcessors; ++i)
	{
		DWORD dwCPUSpeed = ReadCPUSpeedFromRegistry(i);
		ELog::Get().SystemFormat(L"PERF    : * CPU %d speed: ~%dMHz\n", i, dwCPUSpeed);
	}
}

//============================================================================
// Calculate and log the amount of RAM in the machine
//============================================================================
void LogRAM()
{
	// Get memory status
	MEMORYSTATUS theStatus;
	ZeroMemory(&theStatus,sizeof(theStatus));
	theStatus.dwLength = sizeof(theStatus);
	GlobalMemoryStatus(&theStatus);

	// Log it
	DWORD dwRAM = (DWORD)(theStatus.dwTotalPhys/(1024*1024));
	if(theStatus.dwTotalPhys != dwRAM*1024*1024)
		++dwRAM;
	ELog::Get().SystemFormat(L"PERF    : Available physical RAM: %dMB/%dMB\n",
		theStatus.dwAvailPhys/(1024*1024), dwRAM);
}

//============================================================================
// Cetermine OS type
//============================================================================
void LogOS()
{
wchar_t szOS[256];
OSVERSIONINFOEX osInfo;
SYSTEM_INFO sysInfo;

	// Get system info
	ZeroMemory(&sysInfo, sizeof(sysInfo));
	GetSystemInfo(&sysInfo);

	// Get OS version
	wcscpy(szOS, L"PERF    : OS: ");
	ZeroMemory(&osInfo, sizeof(osInfo));
	osInfo.dwOSVersionInfoSize = sizeof(osInfo);
	if(!GetVersionEx((OSVERSIONINFO*)&osInfo))
	{
		ZeroMemory(&osInfo, sizeof(osInfo));
		osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		GetVersionEx((OSVERSIONINFO*)&osInfo);
	}

	// Win 9x
	if(osInfo.dwPlatformId == 1)
	{
		if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 0))
			wcscat(szOS, L"Windows 95 ");
		else if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 10))
			wcscat(szOS, L"Windows 98 ");
		else if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 90))
			wcscat(szOS, L"Windows ME ");
		else
			wcscat(szOS, L"Unknown Windows OS ");
	}

	// Win NT
	else if(osInfo.dwPlatformId == 2)
	{
		if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 0))
			wcscat(szOS, L"Windows NT 4.0 ");
		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 0))
			wcscat(szOS, L"Windows 2000 ");
		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 1))
			wcscat(szOS, L"Windows XP ");
		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 2))
		{
			if(GetSystemMetrics(89))	// SM_SERVERR2 == 89
				wcscat(szOS, L"Windows Server 2003 R2 ");
			else if((osInfo.wProductType == VER_NT_WORKSTATION) &&
				(sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64))
			{
				wcscat(szOS, L"Windows XP Professional x64 Edition ");
			}
			else
				wcscat(szOS, L"Windows Server 2003 ");
		}
		else if((osInfo.dwMajorVersion == 6) && (osInfo.dwMinorVersion == 0))
			wcscat(szOS, L"Windows Vista ");
		else
			wcscat(szOS, L"Unknown WinNT OS ");
	}

	// Unknown
	else
		wcscat(szOS, L"Unknown Operating System ");

	wcscat(szOS, osInfo.szCSDVersion);
	wcscat(szOS, L"\n");

	// Log
	ELog::Get().SystemLog(szOS);
#if defined(BUILD_X64)
	ELog::Get().SystemLog(L"PERF    : Win64 version\n");
#elif defined(_WIN32)
	ELog::Get().SystemLog(L"PERF    : Win32 version\n");
#else
	ELog::Get().SystemLog(L"PERF    : Unknown version\n");
#endif
}


[/edit]
GeneralRe: How get the CPU information ? Pin
bzsolt9112-Aug-09 13:15
bzsolt9112-Aug-09 13:15 
AnswerRe: How get the CPU information ? Pin
Rajesh R Subramanian12-Aug-09 2:42
professionalRajesh R Subramanian12-Aug-09 2:42 
QuestionCSocket Problem on Windows Mobile with WLAN Pin
Member 224636612-Aug-09 1:58
Member 224636612-Aug-09 1:58 
QuestionDoubleclick on MDI Frame Pin
baerten12-Aug-09 1:34
baerten12-Aug-09 1:34 
AnswerRe: Doubleclick on MDI Frame Pin
Stuart Dootson12-Aug-09 6:32
professionalStuart Dootson12-Aug-09 6:32 
QuestionInstalling a driver and Registry settings!! Pin
kapardhi12-Aug-09 0:56
kapardhi12-Aug-09 0:56 
AnswerRe: Installing a driver and Registry settings!! Pin
Randor 12-Aug-09 9:08
professional Randor 12-Aug-09 9:08 
QuestionThread Pin
susanne111-Aug-09 23:46
susanne111-Aug-09 23:46 
AnswerRe: Thread Pin
CPallini12-Aug-09 0:07
mveCPallini12-Aug-09 0:07 
GeneralRe: Thread Pin
susanne112-Aug-09 0:09
susanne112-Aug-09 0:09 
AnswerRe: Thread Pin
CPallini12-Aug-09 0:13
mveCPallini12-Aug-09 0:13 
GeneralRe: Thread Pin
susanne112-Aug-09 0:15
susanne112-Aug-09 0:15 
GeneralRe: Thread Pin
CPallini12-Aug-09 0:56
mveCPallini12-Aug-09 0:56 
AnswerRe: Thread Pin
Rajesh R Subramanian12-Aug-09 0:25
professionalRajesh R Subramanian12-Aug-09 0:25 
GeneralRe: Thread Pin
susanne112-Aug-09 0:27
susanne112-Aug-09 0:27 
GeneralRe: Thread Pin
Rajesh R Subramanian12-Aug-09 1:23
professionalRajesh R Subramanian12-Aug-09 1:23 
GeneralRe: Thread Pin
CPallini12-Aug-09 1:51
mveCPallini12-Aug-09 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.