The Win32 API provides system information data about the environment under which the application is running. This information includes the process environment variables, time, default locale settings for the system and user, system colour settings, drive information, system parameters, OS information, processor type and the computer name. A small selection of these functions are listed below.
For a full description of these functions – https://docs.microsoft.com/en-us/windows/win32/sysinfo/system-information-functions
GetComputerName
Returns the system computer name
BOOL GetComputerName(LPSTR lpBuffer,LPDWORD nSize);
Where
LpBuffer is a pointer to a buffer that receives the computer name or the cluster virtual server name and nSize specifies the size of the buffer. If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
GetSystemDirectory
Retrieves the path of the system directory.
UINT GetSystemDirectoryA(LPSTR lpBuffer,UINT uSize);
Where
PBuffer is a pointer to the buffer to receive the path and USize is the maximum buffer size. If the function succeeds, the return value is the length. If the function fails, the return value is zero.
GetCurrentDirectory
Retrieves the current directory for the current process.
DWORD GetCurrentDirectory(DWORD nBufferLength,LPTSTR lpBuffer);
Where nBufferLength is the buffer length for the current directory string and lpBuffer is a pointer to the buffer that receives the current directory string. If the function succeeds, the return value specifies the number of characters written to the buffer, not including the terminating null character. If the function fails, the return value is zero.
GetEnvironmentVariable
Retrieves the contents of the specified variable from the environment block of the calling process.
DWORD GetEnvironmentVariable(LPCTSTR lpName,LPTSTR lpBuffer,DWORD nSize);
Where
lpName – The name of the environment variable.
lpBuffer – A pointer to a buffer that receives the contents of the specified environment variable as a null-terminated string.
nSize – The buffer size pointed to by the lpBuffer parameter, including the null-terminating character, in characters.
If the function succeeds, the return value is the number of characters stored in the buffer pointed to by. If the function fails, the return value is zero.
GetLocalTime
Retrieves the current local date and time.
void GetLocalTime(LPSYSTEMTIME lpSystemTime);
where lpSystemTime is a pointer to a SYSTEMTIME structure to receive the current local date and time.
Example
The following short program demonstrates various system information functions