|
Hi!
How can I get information about the CPU load (usage), the number of CPUs that are plugged in, the amount of free and total memory, ...?
Many thanx in advance
Tom
|
|
|
|
|
As far as CPU load is concerned, I have not added that functionality as of
yet because the way to do it in Win9x/ME is different than it is for WinNT. I've wanted to do it for some time; maybe I'll get around to it. The other things you ask for are implemented by this class I provided. Here are the commands:
int main(int argc, char* argv[])
{
SysInfo sysInfo;
cout << "---------------------" << endl;
cout << "PROCESSOR INFORMATION" << endl;
cout << "---------------------" << endl;
cout << "CPU String: " << sysInfo.getCpuIdentification() << endl;
cout << "CPU Speed: " << sysInfo.getCpuSpeed() << endl;
cout << "Number of CPUs: " << sysInfo.getNumProcessors() << endl;
cout << "Family: " << sysInfo.getCpuFamily() << endl;
cout << "Model: " << sysInfo.getCpuModel() << endl;
cout << "Stepping: " << sysInfo.getCpuStepping() << endl;
cout << "------------------" << endl;
cout << "MEMORY INFORMATION" << endl;
cout << "------------------" << endl;
cout << "Total: " << sysInfo.getTotalRam() << endl;
cout << "Available: " << sysInfo.getAvailRam() << endl;
cout << "Total Page: " << sysInfo.getTotalPageFile() << endl;
cout << "Avail Page: " << sysInfo.getAvailPageFile() << endl;
cout << "Total Virtual: " << sysInfo.getTotalVirtual() << endl;
cout << "Avail Virtual: " << sysInfo.getAvailVirtual() << endl;
return (0);
}
I've fixed a few bugs since I released this a few months ago, so e-mail me if you'd like the updated version. I'll try to get around to that load usage stuff, too. It's hard to find incentive to do these things when I, myself, don't need them because I have other things going on
|
|
|
|
|
void hardware_info()
{
SYSTEM_INFO siSysInfo;
// Copy the hardware information to the SYSTEM_INFO structure.
GetSystemInfo(&siSysInfo);
// Display the contents of the SYSTEM_INFO structure.
printf("Hardware information: \n");
printf(" OEM ID: %u\n", siSysInfo.dwOemId);
printf(" Number of processors: %u\n",
siSysInfo.dwNumberOfProcessors);
printf(" Page size: %u\n", siSysInfo.dwPageSize);
printf(" Processor type: %u\n", siSysInfo.dwProcessorType);
printf(" Minimum application address: %lx\n",
siSysInfo.lpMinimumApplicationAddress);
printf(" Maximum application address: %lx\n",
siSysInfo.lpMaximumApplicationAddress);
printf(" Active processor mask: %u\n",
siSysInfo.dwActiveProcessorMask);
}
void version_number()
{
DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
dwVersion = GetVersion();
// Get the Windows version.
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get the build number.
if (dwVersion < 0x80000000)
dwBuild = (DWORD)(HIWORD(dwVersion));
printf("Version Number is %d.%d (%d)\n",
dwMajorVersion,
dwMinorVersion,
dwBuild);
}
#define DIV 1024
// Specify the width of the field in which to print the numbers.
// The asterisk in the format specifier "%*I64d" takes an integer
// argument and uses it to pad and right justify the number.
#define WIDTH 7
void memory_info()
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);
printf ("There is %*ld percent of memory in use.\n",
WIDTH, statex.dwMemoryLoad);
printf ("There are %*I64d total Kbytes of physical memory.\n",
WIDTH, statex.ullTotalPhys/DIV);
printf ("There are %*I64d free Kbytes of physical memory.\n",
WIDTH, statex.ullAvailPhys/DIV);
printf ("There are %*I64d total Kbytes of paging file.\n",
WIDTH, statex.ullTotalPageFile/DIV);
printf ("There are %*I64d free Kbytes of paging file.\n",
WIDTH, statex.ullAvailPageFile/DIV);
printf ("There are %*I64d total Kbytes of virtual memory.\n",
WIDTH, statex.ullTotalVirtual/DIV);
printf ("There are %*I64d free Kbytes of virtual memory.\n",
WIDTH, statex.ullAvailVirtual/DIV);
// Show the amount of extended memory available.
printf ("There are %*I64d free Kbytes of extended memory.\n",
WIDTH, statex.ullAvailExtendedVirtual/DIV);
}
|
|
|
|
|
sir,
it would be more greatly appreciated if you add these features:
- Detect Lan Adapters with it Manufacturers Name and Model...
- Detct Motherboard with Manufacturers name
- Detect Display Monitor With Manufacturers Name
- Detect Keyboard and Mouse
- Detect Display Adapter with manufacturers Name
- and lastly it will detect other PCI and ISA devices installed...
hope it will come out in the next release..
i just love your stuff....
thanks
xjhay
xjhay
|
|
|
|
|
Hi,
Can you please explain how should I compile this program? I pretty exhaustive and I dont know why we are having two zip files one for testing and one for source. I have used the source zip file to create a dll, it works fine and compiles without any errors. But when I am compiling the tester code, it says:
Compiling...
SysInfoTester.cpp
Linking...
LINK : fatal error LNK1104: cannot open file "SysInfo.lib"
Error executing link.exe.
SysInfoTester.exe - 1 error(s), 0 warning(s)
Can anyone tell me how to solve this.
Suren.
|
|
|
|
|
Hi All,
I cannot link it too... Please help..
Yacx.
|
|
|
|
|
Hello,
I'm sorry that you've been left hanging for a while;
I simply didn't know anyone was looking at this
message board (I thought you'd get an e-mail when
someone replied, but perhaps that doesn't hold true
for main articles).
Anyway, the problem is that I used two separate projects,
each with their own workspace. All you have to do is
copy the output libraries that the source zip file creates
into a directory in your library path. Once you link the tester
program, it'll find these libraries and link them in. You
could also copy the libraries from the SysInfo output
directories directly to the same location as SysInfoTester.dsp.
A lot of people have been confused by my segregated
approach, which may seem very awkward, though it was
necessary for me to do at the time. As soon as I figure out
how to update this article with new source code, I will do so.
I have since combined the projects so that it's actually
a no-brainer to build
--Paul
|
|
|
|
|
Hello,
I'm sorry that you've been left hanging for a while;
I simply didn't know anyone was looking at this
message board (I thought you'd get an e-mail when
someone replied, but perhaps that doesn't hold true
for main articles).
Anyway, the problem is that I used two separate projects,
each with their own workspace. All you have to do is
copy the output libraries that the source zip file creates
into a directory in your library path. Once you link the tester
program, it'll find these libraries and link them in. You
could also copy the libraries from the SysInfo output
directories directly to the same location as SysInfoTester.dsp.
A lot of people have been confused by my segregated
approach, which may seem very awkward, though it was
necessary for me to do at the time. As soon as I figure out
how to update this article with new source code, I will do so.
I have since combined the projects so that it's actually
a no-brainer to build
--Paul
|
|
|
|
|
If you are still looking at this article ever, would you please reply to this post. I'm looking for the combined project for this article.
You should be able to contact me via email on CodeProject (E-Mail link).
Thank You!
Frank V.
www.TheOpenSourceU.com
|
|
|
|
|
No returned speed from an AMD K6-2 500Mhz Processor.
|
|
|
|
|
I have an updated version which may address this. I have
no K6-2 processor to test on, but it does work on my
Athlons....
If I can figure out how to post an update on here, I will.
--Paul
|
|
|
|
|
I was wondering if you have created a managed code version (.net dll)?
|
|
|
|
|
Hello,
I have not done anything like this as of yet. I haven't
really looked too closely at C# yet (I was waiting for
the release for a while).
--Paul
|
|
|
|
|
I'm working on an update to add a few extras like keyboard,mouse,locale.
Great work. Has been easy to add too.
Michael
|
|
|
|
|
Good. The only thing I don't really like about the submission, conceptually, is the SysInfo class having
"wrapper functions" that get at the derived helper classes. Unfortunately, I like this method more than
exposing the helper classes as public. When you make your updates, would you mind posting the code
on here? It'd be great; I plan on adding some support for IE-version detection, comctl32 version detection,
and some other stuff that I can't remember right now.
--Paul
|
|
|
|
|
Paul,
Here is a quick list of what I've got done and plan to do. Project files
to come back at you sometime in the next week (or so) depending on my
available freetime.
DONE
----
Added static built TestApp to existing project file
CPUInfo added a registry based CPUSpeed (not happy with it yet)
OSInfo now adds DtWinVer information
MouseInfo new addition (with notes/code for more items to add)
KeyboardInfo new addition (with notes/code for more items to add)
LocaleInfo new addition (internationalization info)
MultimediaInfo new addition (soundcard info)
Changed the name fo SysInfoTester to ConSysInfo
- this helps with later adding DlgSysInfo testing app (I like GUI apps)
TODO
----
More Harddisk/Media information
More Network/Socket information
Try for PnP device information
--
Michael McGarrah
|
|
|
|
|
This all sounds great to me. I'd like to get DirectX, IE, Common Control, and other information too. We can add that to the TODO list as well . You're right about the ConSysInfo project. The only reason I made a console application was actually because I didn't want to fuss around with using std::string in a dialog [i'm a DDX/DDV nut -- read: i haven't done it with std::string yet].
--Paul
|
|
|
|
|
Doesn't DDX/DDV take advantage of operator=() ? I haven't tried it myself, but it should work seemlessly..
|
|
|
|
|
Honestly, I don't think so ... at least not by default. What I mean is that there are function calls that take CString arguments ... DDX_Test, I think? It's something like that anyway. In addition, though, I know for a fact that if you use CString, it asks you how many characters you want to limit it to; I'm guessing that it's either using CString::GetLength() or taking advantage of the (LPCTSTR) cast. std::string has neither of these.
It wouldn't be hard to just SetWindowText()/GetWindowText() with std::string::c_str(); however, I just didn't want to mess with it at the time.
|
|
|
|
|
Why don't you just write your own DDX/DDV functions that take a std::string instead of a CString? These functions are not that hard to write (There is a Knowledge Base and MSDN article on it, I just can't remember the title or the numbers).
Zac Howland
|
|
|
|
|