System Information

This section details Windows API functions for retrieving system-wide information, including details about the operating system, hardware, and user sessions.

Core System Information Functions

GetSystemInfo

Retrieves information about the current system, including processor architecture, number of processors, and page size.

VOID GetSystemInfo(
    LPSYSTEM_INFO lpSystemInfo
);

Parameters

  • lpSystemInfo: A pointer to a SYSTEM_INFO structure that receives the system information.

Remarks

This function is generally used to determine the architecture and capabilities of the system at runtime.

SYSTEM_INFO structure

Contains information about the current computer (for example, the processor architecture and the system's Hôm page size).

typedef struct _SYSTEM_INFO {
    union {
        DWORD dwOemId;
        struct {
            WORD wProcessorArchitecture;
            WORD wReserved;
        }
    } DUMMYUNIONNAME;

    DWORD dwPageSize;
    LPVOID lpMinimumApplicationAddress;
    LPVOID lpMaximumApplicationAddress;
    DWORD_PTR dwActiveProcessorMask;
    DWORD dwNumberOfProcessors;
    DWORD dwProcessorType;
    DWORD dwAllocationGranularity;
    WORD wProcessorLevel;
    WORD wProcessorRevision;
`} SYSTEM_INFO, *LPSYSTEM_INFO;

Members

  • dwPageSize: The size of a page in bytes.
  • dwNumberOfProcessors: The number of logical processors on the current system.
  • dwProcessorType: An identifier for the processor architecture of the installed processor.

Memory Information

GlobalMemoryStatusEx

Retrieves current information about the amount of physical memory and allocation preferences. This is a more comprehensive version of GlobalMemoryStatus.

BOOL GlobalMemoryStatusEx(
    LPMEMORYSTATUSEX lpBuffer
);

Parameters

  • lpBuffer: A pointer to a MEMORYSTATUSEX structure that receives information about the current memory status.

Return Value

TRUE if the function succeeds, FALSE otherwise.

MEMORYSTATUSEX structure

Contains information about the current memory status. The structure specifies the size of the structure, the approximate percentage of memory that is occupied by usable committed memory, and information about physical and virtual memory.

typedef struct _MEMORYSTATUSEX {
    DWORD dwLength;
    DWORD dwMemoryLoad;
    SIZE_T ullTotalPhys;
    SIZE_T ullAvailPhys;
    SIZE_T ullTotalPageFile;
    SIZE_T ullAvailPageFile;
    SIZE_T ullTotalVirtual;
    SIZE_T ullAvailVirtual;
    SIZE_T ullAvailExtendedVirtual;
`} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;

Members

  • ullTotalPhys: The total size of physical memory, in bytes.
  • ullAvailPhys: The available physical memory, in bytes.
  • ullTotalPageFile: The current size of the committed memory, in bytes.

Other System Information

GetComputerName

Retrieves the name of the computer. This name can be the NetBIOS name or the DNS name.

BOOL GetComputerName(
    LPTSTR lpBuffer,
    LPDWORD nSize
);

Parameters

  • lpBuffer: A pointer to a buffer that receives the computer name.
  • nSize: A pointer to a variable that specifies the size of the buffer, in characters.

GetVersionEx

Retrieves version information for the currently running Windows operating system. Note: This function is deprecated. Use GetVersionExW or the VerifyVersionInfo function.

BOOL GetVersionEx(
    LPOSVERSIONINFO lpVersionInformation
);

Parameters

  • lpVersionInformation: A pointer to an OSVERSIONINFO structure that receives the operating system version information.

OSVERSIONINFO structure

Contains information about the version of the operating system. This structure is returned by the GetVersionEx function.

typedef struct _OSVERSIONINFO {
    DWORD dwOSVersionInfoSize;
    DWORD dwMajorVersion;
    DWORD dwMinorVersion;
    DWORD dwBuildNumber;
    DWORD dwPlatformId;
    TCHAR szCSDVersion[128];
`} OSVERSIONINFO, *LPOSVERSIONINFO;

Members

  • dwMajorVersion: Specifies the major version number of the operating system.
  • dwMinorVersion: Specifies the minor version number of the operating system.
  • dwBuildNumber: Specifies the build number of the operating system.