Sunday, June 28, 2009

How to find out system information on Window

Sometimes, we need to know the properties of the OS we are running on,
such information of interests include, page size, etc. On Linux this
is quite easy to get, because Linux has the proc file system to export
kernel information to user land as a file systems. On Windows I haven't
known a good and easy way. But Win32 API has a GetSystemInfo call,
which fulfills most of the need. Below is the sample code to print out
the page size of Windows.

#include <stdio.h>
#include <windows.h>

int main() {
SYSTEM_INFO si;
GetSystemInfo(&si);

printf("The page size for this system is %u bytes.\n", si.dwPageSize);

return 0;
}

No comments:

Post a Comment