Question

I need to make application which gathers basic data about system, like OS version, processor & memory type, data about installed programs... Application will be written in c and will work on Win Server 2000 and 2003. So first thing on my mind was WinApi, but i can not find any tutorials for these things, every tutorial i found is about UserInterfaces and i do not need that.

So any help would be appreciated.

EDIT: Couple of things are answered below, and i will use WMI with WinApi, but still i dont know how to get detailed properties from any .exe program on windows??

Was it helpful?

Solution

WMI is likely what you need for some stuff. Not a fun API. The tool Hans refers to would be useful - even if you have to port the generated C# code back to C.

The following Win32 APIs are likely to help you:

OS Version: GetVersionEx and OSVERSIONINFOEX

CPU Info: cpuid (either write it in assembly, or call the compiler intrinsic)

Alternate CPU Info: Just look at the registry key in HKLM\Hardware\DESCRIPTION\System\CentralProcessor (1 subkey for each logical processor, each key is a cache of what cpuid returns + processor speed is listed as well).

Memory: GlobalMemoryStatusEx

OTHER TIPS

This isn't covered by the Winapi, you need WMI (Windows Management Instrumentation). To get started on the kind of queries you can run, experiment with the WMI Code Creator tool. It can auto-generate the code you need. Not in C, you'll find that quite an awkward language for WMI.

You probably also want to know about the book Windows Internals, from the same folk who make a wide range of cool utilities for poking under the hood.

For Processor Information call GetLogicalProcessorInformation.

Be Aware that this is not supported on all machines. So its better to call the DLL dynamically. Otherwise your program wont run on such machines. This example show how to do this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top