to swxh(中重):
呵呵,给码子吧,偶特菜
呵呵,给码子吧,偶特菜
解决方案 »
- 请教问题。。。
- MFC如何控制Combo Box中只能输入三位数字(可以有小数点)
- CInternetSession 实现http代理
- 系统资源不足,无法完成请求,内存也不增,什么原因?
- CString GetBuffer以后调用ReleaseBuffer可以重新计算长度,STL的string有类似的功能吗?
- 很急,几经好久了,我还是不会.使用线程,如何将进度在状态条中显示呀,谢谢
- 谁知道哪里有cj60lib 的6.08或6.09 版本?
- 大侠救我,明天要教作业了啊!!up有分
- CRecordset::GetRecordCount怎么用啊 我不管怎么用得到的老是1 虽然记录数不止那么点
- 我想用vc写一个能进行网络广播的多媒体软件,望各位大虾帮帮忙
- 这有什么错啊?怎么没数据返回的???(30分)
- 考考你们这些假洋鬼子?
CPU Information:
To get CPU information I could not find any direct and simple API call. Then I thought of our friendly Registry, which contains all the system information. And there it was all the information I wanted. If you look under HKEY_LOCAL_MACHINE/Hardware/Description/System/CentralProcessor/0 key in registry, you will find the answers to your questions. ~MHz subkey gives the CPU speed and VendorIdentifier gives the vendor information. We will make use of RegQueryValueEx API call to get the information. LONG RegQueryValueEx(
HKEY hKey, // handle to key to query
LPTSTR lpValueName, // address of name of value to query
LPDWORD lpReserved, // reserved
LPDWORD lpType, // address of buffer for value type
LPBYTE lpData, // address of data buffer
LPDWORD lpcbData // address of data buffer size
);
Before making this call, it is necessary to create the handle to registry key which needs to be queried. For this make use of RegCreateKeyEx API call.
This is how the code looks like in the included code for this utility.
// Get the processor speed info.result = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE,
"Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey);// Check if the function has succeeded.if (result == ERROR_SUCCESS) {
result = ::RegQueryValueEx (hKey, _T("~MHz"), NULL, NULL,
(LPBYTE)&data, &dataSize);
m_stCPUSpeed.Format ("%d", data);
m_stCPUSpeed += _T (" MHz"); dataSize = sizeof (vendorData); result = ::RegQueryValueEx (hKey, _T("VendorIdentifier"), NULL, NULL,
(LPBYTE)vendorData, &dataSize); m_stVendorInfo.Format ("%s", vendorData);
}// Make sure to close the reg keyRegCloseKey (hKey);
Since I don't have access to any other CPU than Intel. So I couldn't test this code on CPU's from Cyrix, AMD, etc. Physical Memory Status:
To get the information about the memory status of the system we can take routes. First one, which is not easy for a person who does not know assembly language, involves getting the required information from CMOS data. Second one which simply involves making GlobalMemoryStatus API call. And I chose the second one (Ofcourse I am not assembly language pro). VOID GlobalMemoryStatus (
LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);
The information is returned in MEMORYSTATUS data structure. typedef struct _MEMORYSTATUS { // mst
DWORD dwLength; // sizeof(MEMORYSTATUS)
DWORD dwMemoryLoad; // percent of memory in use
DWORD dwTotalPhys; // bytes of physical memory
DWORD dwAvailPhys; // free physical memory bytes
DWORD dwTotalPageFile; // bytes of paging file
DWORD dwAvailPageFile; // free bytes of paging file
DWORD dwTotalVirtual; // user bytes of address space
DWORD dwAvailVirtual; // free user bytes
} MEMORYSTATUS, *LPMEMORYSTATUS;
The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information. This API call has been made in GetMemoryInfo function of the application attached. I gets the information for memory usage, total physical memory instaled, physical memory available, and total virtual memory.
http://codeguru.earthweb.com/mfc/comments/31157.shtml
http://www.csdn.net/Expert/topic/499/499189.shtm