Windows API Reference

System Information Functions

The System Information functions provide access to various details about the Windows operating system, hardware, and system configuration. This information can be crucial for developing applications that adapt to different environments or require specific system capabilities.

Key Concepts

Commonly Used Functions

The following table lists some of the most frequently used functions for accessing system information:

Function Name Description Category
GetVersionEx Retrieves extended information about the current operating system. OS Version
GetSystemInfo Fills a SYSTEM_INFO structure with information about the current system (e.g., processor type, page size). System Hardware
GlobalMemoryStatusEx Retrieves information about the current memory availability (e.g., total physical memory, available physical memory). Memory
GetComputerName Retrieves the name of the computer. System Identification
GetUserName Retrieves the name of the user currently logged on to the system. User Information
GetTickCount64 Retrieves the number of milliseconds since the system was started. System Time
QueryPerformanceCounter Retrieves the current value of the performance counter, which is a high-resolution time source. Performance
GetEnvironmentVariable Retrieves the value of a specified environment variable. Environment

Example: Getting System Information

Here's a C++ example demonstrating how to retrieve basic system information:

#include <windows.h>
#include <iostream>

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

    MEMORYSTATUSEX memInfo;
    memInfo.dwLength = sizeof(MEMORYSTATUSEX);
    GlobalMemoryStatusEx(&memInfo);

    std::cout << "--- System Information ---" << std::endl;
    std::cout << "Processor Architecture: " << sysInfo.wProcessorArchitecture << std::endl;
    std::cout << "Number of Processors: " << sysInfo.dwNumberOfProcessors << std::endl;
    std::cout << "Page Size: " << sysInfo.dwPageSize << " bytes" << std::endl;
    std::cout << "Total Physical Memory: " << memInfo.ullTotalPhys / (1024 * 1024) << " MB" << std::endl;
    std::cout << "Available Physical Memory: " << memInfo.ullAvailPhys / (1024 * 1024) << " MB" << std::endl;

    return 0;
}