|
Hello,
How can i get the CPU information under VC++ (cpu modelname,cpu speed).
THNX for help!
|
|
|
|
|
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>
DWORD ReadCPUSpeedFromRegistry(DWORD dwCPU)
{
HKEY hKey;
DWORD dwSpeed;
wchar_t szKey[256];
_snwprintf(szKey, sizeof(szKey)/sizeof(wchar_t),
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d\\", dwCPU);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
{
return 0;
}
DWORD dwLen = 4;
if(RegQueryValueEx(hKey, L"~MHz", NULL, NULL, (LPBYTE)&dwSpeed, &dwLen) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return 0;
}
RegCloseKey(hKey);
return dwSpeed;
}
void LogCPU()
{
unsigned nHighestFeature;
unsigned nHighestFeatureEx;
int nBuff[4];
char szMan[13];
char szFeatures[256];
unsigned nProcessorType;
__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;
__cpuid(nBuff, 0x80000000);
nHighestFeatureEx = (unsigned)nBuff[0];
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);
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 ");
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 ");
}
if(nProcessorType == PROCESSOR_AMD)
{
__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 ");
}
if(nHighestFeatureEx >= 0x80000005)
{
__cpuid(nBuff, 0x80000005);
ELog::Get().SystemFormat(L"PERF : L1 cache size: %dK\n", ((unsigned)nBuff[2])>>24);
}
}
if(nHighestFeatureEx >= 0x80000006)
{
__cpuid(nBuff, 0x80000006);
ELog::Get().SystemFormat(L"PERF : L2 cache size: %dK\n", ((unsigned)nBuff[2])>>16);
}
ELog::Get().SystemFormat(L"PERF : CPU Features: %S\n", szFeatures);
SYSTEM_INFO theInfo;
GetSystemInfo(&theInfo);
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);
}
}
void LogRAM()
{
MEMORYSTATUS theStatus;
ZeroMemory(&theStatus,sizeof(theStatus));
theStatus.dwLength = sizeof(theStatus);
GlobalMemoryStatus(&theStatus);
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);
}
void LogOS()
{
wchar_t szOS[256];
OSVERSIONINFOEX osInfo;
SYSTEM_INFO sysInfo;
ZeroMemory(&sysInfo, sizeof(sysInfo));
GetSystemInfo(&sysInfo);
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);
}
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 ");
}
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))
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 ");
}
else
wcscat(szOS, L"Unknown Operating System ");
wcscat(szOS, osInfo.szCSDVersion);
wcscat(szOS, L"\n");
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]
|
|
|
|
|
In vc++ got some error.
For example error C2653: 'ELog' : is not a class or namespace name.
I can't compile it.
|
|
|
|
|
|
Hi,
I'm working on a Windows Mobile application that connects to a server on a PC.
The problem with the following lines:
CSocket as;
if(!as.Create())
MessageBox(_T("creation failed"));
if(as.Connect(_T("192.168.1.24"), 110))
MessageBox(_T("connected"));
else
MessageBox(_T("failed to connect"));
is, that Connect(...) allways returns TRUE, even if the server isn't started and even if the PC with the IP address 192.168.1.24 is switched off.
This error only occures with Windows Mobile and a WLAN connection. On Windows XP/Vista connected via WLAN/LAN or Windows Mobile connected via USB Connect(...) returns FALSE when there's no server.
Any hints?
Thanks,
Thomas
ps.: to be a bit more precise - the problematic connection is from a PDA via WLAN to a Netgear internet router and the PC is connected via LAN
|
|
|
|
|
Hi everybody,
I like to catch the doubleclick on the MDI Frame.
Not somewhere into the Frame, rather on the titlebar of the frame itself.
In PreTranslateMessage of the MDIChildWnd I tried already to catch the message
WM_LBUTTONDBLCLK, but it seems that this message is never handled to this frame.
Has anyone an idea?
Big thanks
|
|
|
|
|
Knowing how frames work for normal windows, I suspect you want to look for WM_NCLBUTTONDBLCLK, i.e. the non-client area equivalent of WM_LBUTTONDBLCLK
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hai!
Is there any key in the registry which changes its value each time i install and uninstall the driver for a smart card reader!!
Thanks!
|
|
|
|
|
There are many registry settings changing. What is the purpose of this question? Why do you need to know registry modifications?
There are too many to list and some are vendor specific. Locate the driver installation package for your smartcard device and open the INF file. Registry modifications are located in the 'AddReg' sections. You can also install an installation monitor and log the registry changes.
Best Wishes,
-David Delaune
|
|
|
|
|
Hallo,
I have the following problem with the Thread:
I create the Thread first as SUSPENDED, but it does not start at the expectetd time.
First the Program calls this function:
ThreadStart();
///////////////////////////////
ThreadStart()
{
if (m_pSelThread != NULL)
{
if (::WaitForSingleObject(m_pSelThread->m_hThread, 0) != WAIT_OBJECT_0)
return;
delete m_pSelThread;
m_pSelThread = NULL;
}
::WaitForSingleObject(m_SEl_Start_Event, 0);
m_SEl_Start_Event.SetEvent (); // CEvent Object
CWinThread* m_pSelThread = AfxBeginThread(ThreadFunktion, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
m_pSelThread->m_bAutoDelete = FALSE;
m_pSelThread->ResumeThread();
}
UINT ThreadFunktion
(
LPVOID param
)
{
if (param == NULL)
return -1;
DoSomeThing();
return 0;
}
The Thread does not come to the UINT ThreadFunktion(LPVOID param).
Any help would be appriciated.
|
|
|
|
|
susanne1 wrote: CWinThread* m_pSelThread = AfxBeginThread(ThreadFunktion, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
Shouldn't that be:
m_pSelThread = AfxBeginThread(ThreadFunktion, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
i.e. you're hiding the class member variable with the local one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Okay i did it like that defining the Thread Pointer in the header File, but this deos not help.
|
|
|
|
|
susanne1 wrote: ::WaitForSingleObject(m_SEl_Start_Event, 0);
What is the purpose of the above call?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
to wait for the event to happen.
|
|
|
|
|
That doesn't make sense. Anyway I made a test on my system:
Without hiding the class member variable, the thread starts happily.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can't you just start the thread and wait for the event to happen within the thread before executing code? What's all this mess about? Why are you setting the m_bAutoDelete member to false? I see you may delete it manually, but *what* is the purpose of it?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
the thread mus t be created but not start immediately, autodelte false to tell him not to delet himself.
|
|
|
|
|
So, why should it not start immediately? Can't you just start it immediately, but not execute any code until the interested event happens? I asked for the reason behind your approach. I did not ask you what m_bAutoDelete is for. Tell me why do *you* want the thread not to delete itself.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: Why are you setting the m_bAutoDelete member to false? I see you may delete it manually, but *what* is the purpose of it?
Well you may want to do that, I mean that's nothing wrong in doing it (and that's the reason for delaying the thread start).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No, I asked why did he want to delete it manually (as opposed to leave it die in its way). There could be valid reasons, I wanted to know the OP's reason.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You're right: there could be valid reasons, anyway you're very (and, of course, politely) curious about her reason.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Of course, politeness is guaranteed (or 100% money back), after Mr. Maunder's new commandment.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
BTW there's a polite way to advice someone to stop using threads?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, August 12, 2009 10:59 AM
|
|
|
|
|
I have a dialog based application with WebBrower control on it.
The URL that i open in the webbrowser uses script having Windows.close() method.
When the URL is closing it calls OnWindowClosing Browser Method, and later post a message saying "The webpage you're viewing is trying to close this window. Do you want to close this window? - YES/NO"
My issue is on clicking YES the dialog is not closing.
What should i do to close the dialog on selecting YES in above dialog.
And secondly, i want the application to return 22 on clicking YES. How to may Dialog application return 22 on clicking YES above.
Thank you..
|
|
|
|
|
Member 3834630 wrote: My issue is on clicking YES the dialog is not closing.
After the browser control is closed are you relaying that event to the dialog or attempting to close the dialog with a call to EndDialog()?
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|