Jump to content
  • Advertisement
Sign in to follow this  
cptrnet

Getting Sytsem Info?

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I get system information, hardware information. Such as processor info, memory info, disk space, graphics card, I would like to do it through win32 and directx. I was looking at the SYSTEM_INFO structure but I don't know how to use it, it gives an example on msdn but it only gives me back weird numbers.

Share this post


Link to post
Share on other sites
Advertisement
For disk space this looks like the function you'll need


BOOL GetDiskFreeSpaceEx(

LPCTSTR lpDirectoryName, // pointer to directory name on disk of interest
PULARGE_INTEGER lpFreeBytesAvailableToCaller, // pointer to variable to receive free bytes on disk available to the caller
PULARGE_INTEGER lpTotalNumberOfBytes, // pointer to variable to receive number of bytes on disk
PULARGE_INTEGER lpTotalNumberOfFreeBytes // pointer to variable to receive free bytes on disk
);




This is for the type of disk



UINT GetDriveType(LPCTSTR lpRootPathName // address of root path
);

Return Types

0 The drive type cannot be determined.
1 The root directory does not exist.
DRIVE_REMOVABLE The drive can be removed from the drive.
DRIVE_FIXED The disk cannot be removed from the drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.


For memory status



VOID GlobalMemoryStatus(

LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);



Share this post


Link to post
Share on other sites
I just get processor info via the Assembly CPUID instruction (you can read all about in Intel's docs: ftp://download.intel.com/support/processors/procid/24161815.pdf, but it requires some Assembly knownledge)


Memory info:
MEMORYSTATUS ms;
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&ms);
// total RAM
ms.dwTotalPhys
// available RAM
ms.dwAvailPhys


I've written these functions (actually, the first one is taken directly from the Intel docs, because I couldn't optimze it further) in (Intel style) Assembly, compiled with NASM. The first one checks for CPUID support (it should be supported by all >= 486) and the next returns the registers after executing the CPUID instruction. Both of them are written for the cdecl calling convention (the standard C/C++ calling convention).

global _CheckCPUID
global _CPUID

[segment .code]

_CheckCPUID:
pushfd
pop eax
mov ecx, eax
xor eax, 200000h
push eax
popfd
pushfd
pop eax
xor eax, ecx
je check_cpuid_1
mov eax, 1
jmp check_cpuid_2
check_cpuid_1:
xor eax, eax
check_cpuid_2:
ret

_CPUID:
mov eax, [esp + 4]
cpuid
push eax
mov eax, [esp + 16]
mov [eax], ebx
mov eax, [esp + 20]
mov [eax], ecx
mov eax, [esp + 24]
mov [eax], edx
pop eax
mov ebx, [esp + 8]
mov [ebx], eax
ret








The C function definitions for these (when linked to the program) looks:

bool CheckCPUID();
// ulong = unsigned long (of course)
void CPUID(ulong mode, ulong *eax, ulong *ebx, ulong *ecx, ulong *edx);


But it can be quite a task to detect the exact processor (like Pentium 4 2.8 GHz instead of Intel 2.8 GHz), because there's so many combinations. I just get the vendor string (GenuineIntel or AuthenticAMD), the frequency and the relevant extensions (MMX, SSE, SSE2, SSE3, 3DNow!) plus some others (HTT, EM64T), just to get a little more info.

[Edited by - nife on July 23, 2005 3:15:52 PM]

Share this post


Link to post
Share on other sites
A lot of that info is in the Registry...

Registry key for Processor info:

HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
ProcessorNameString (NT)
Identifier (95/98)
VendorIdentifier

Registry key to find Registry key for Win2000/XP Graphics Cards

HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO
\Device\Video0 <--- keyname

(use the key pointed to by \Device\Video0 to find the Graphics card info)
"Device Description"

Operating System info:

Use "GetVersionInfoEx()" to find out whether your user is on (95/98) or (NT/2000/XP)... then, either:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

CSDVersion (Service pack) (NT ONLY)
CurrentBuildNumber (NT only)
ProductName
RegisteredOwner
Version (95/98)
VersionNumber (95/98)


---

I almost asked the same question you did a few days ago, but researched these myself...

I'm still wondering how to get:

*CPU Speed

*Display setting (desktop dimensions, & bitdepth)... these are probably in DirectX though...

Share this post


Link to post
Share on other sites
Quote:
Original post by Verg
A lot of that info is in the Registry...

Registry key for Processor info:

HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
ProcessorNameString (NT)
Identifier (95/98)
VendorIdentifier

Registry key to find Registry key for Win2000/XP Graphics Cards

HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\VIDEO
\Device\Video0 <--- keyname

(use the key pointed to by \Device\Video0 to find the Graphics card info)
"Device Description"

Operating System info:

Use "GetVersionInfoEx()" to find out whether your user is on (95/98) or (NT/2000/XP)... then, either:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

CSDVersion (Service pack) (NT ONLY)
CurrentBuildNumber (NT only)
ProductName
RegisteredOwner
Version (95/98)
VersionNumber (95/98)


---

I almost asked the same question you did a few days ago, but researched these myself...

I'm still wondering how to get:

*CPU Speed

*Display setting (desktop dimensions, & bitdepth)... these are probably in DirectX though...




int GetSystemMetrics(

int nIndex // system metric or configuration setting to retrieve
);

with SM_CXSCREEN and SM_CYSCREEN for dimensions or GetDeviceCaps(hdc,
with DESKTOPHORZRES or DESKTOPVERTREZ

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!