Getting Sytsem Info?
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.
For disk space this looks like the function you'll need
This is for the type of disk
For memory status
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 Types0 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 );
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)
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).
The C function definitions for these (when linked to the program) looks:
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]
Memory info:MEMORYSTATUS ms;ms.dwLength = sizeof(MEMORYSTATUS);GlobalMemoryStatus(&ms);// total RAMms.dwTotalPhys// available RAMms.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 _CheckCPUIDglobal _CPUID[segment .code]_CheckCPUID:pushfdpop eaxmov ecx, eaxxor eax, 200000hpush eaxpopfdpushfdpop eaxxor eax, ecxje check_cpuid_1mov eax, 1jmp check_cpuid_2check_cpuid_1:xor eax, eaxcheck_cpuid_2: ret_CPUID:mov eax, [esp + 4]cpuidpush eaxmov eax, [esp + 16]mov [eax], ebxmov eax, [esp + 20]mov [eax], ecxmov eax, [esp + 24]mov [eax], edxpop eaxmov ebx, [esp + 8]mov [ebx], eaxret
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]
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...
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...
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
The GetSystemInfo method is what uses the SYSTEM_INFO struct (MSDN Link)
You may wish to also look at the System Information Functions reference.
You may wish to also look at the System Information Functions reference.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement