How to detect some system info at runtime?

Hi!

I'm programming under Linux and I wish to detect the following info at runtime, but I need a cross-platform solution:
> OS (Linux/Unix, Windows or MacOSX)
> OS version (string and/or integer)
> Direct3D version (8 or 9, IF under Windows, of course)
> OpenGL version (IF present)
> Total video memory
> Total system memory
> CPU frequency (may be like 1, 2, 3 (GHz). No need to be precise)
> Max screen width (resolution)
> Max screen height (resolution)
> Max bits (resolution) (16, 32)


I've already researched the net, but I only find compile time solutions. :(

I would thank a lot the help :)
For your needs you have to use operating system API. So I don't think you can do this at runtime, because you have to link your app against the API libraries of the specific OS.

Only things you can do at runtime will be

> OpenGL version (IF present)
> Total video memory
> Total system memory
> CPU frequency (may be like 1, 2, 3 (GHz). No need to be precise)

Hmm, not bad...
But, not even using ASM?
> OS (Linux/Unix, Windows or MacOSX)

You can't detect this at runtime, use compiler macros, check for WIN32 macro for windows
OS version (string and/or integer)

GetVersionEx() under windows
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx
> Direct3D version (8 or 9, IF under Windows, of course)

DirectXSetupGetVersion()
1
2
3
4
5
6
7
8
DWORD dwVersion;
DWORD dwRevision;
if (DirectXSetupGetVersion(&dwVersion, &dwRevision))
{
    printf("DirectX version is %d.%d.%d.%d\n",
           HIWORD(dwVersion), LOWORD(dwVersion),
           HIWORD(dwRevision), LOWORD(dwRevision));
}


> OpenGL version (IF present)

glGetString() - hopefully it is cross-platform, in windows this works
http://www.opengl.org/sdk/docs/man/xhtml/glGetString.xml

> Total video memory

http://www.opengl.org/discussion_boards/showthread.php/166508-Methods-for-getting-dedicated-VRam-size

> Total system memory

GlobalMemoryStatus() for windows

> Max screen width (resolution)
> Max screen height (resolution)
> Max bits (resolution) (16, 32)


GetSystemMetrics() for windows with appropiate flags every time
Thanks!
Topic archived. No new replies allowed.