| Version: 3.2.2

Functions
Network, User and OS
Functions and Macros by Category

## Detailed Description

The functions in this section are used to retrieve information about the current computer and/or user characteristics.

Related class group: Networking, wxPlatformInfo.

## Functions

wxString | wxGetEmailAddress ()
| Copies the user's email address into the supplied buffer, by concatenating the values returned by wxGetFullHostName() and wxGetUserId(). More...
bool | wxGetEmailAddress (char *buf, int sz)
wxMemorySize | wxGetFreeMemory ()
| Returns the amount of free memory in bytes under environments which support it, and -1 if not supported or failed to perform measurement. More...
wxString | wxGetHomeDir ()
| Return the (current) user's home directory. More...
wxString | wxGetHostName ()
| Copies the current host machine's name into the supplied buffer. More...
bool | wxGetHostName (char *buf, int sz)
wxString | wxGetFullHostName ()
| Returns the FQDN (fully qualified domain host name) or an empty string on error. More...
wxString | wxGetUserHome (const wxString &user=wxEmptyString)
| Returns the home directory for the given user. More...
wxString | wxGetUserId ()
| This function returns the "user id" also known as "login name" under Unix (i.e. More...
bool | wxGetUserId (char *buf, int sz)
wxString | wxGetUserName ()
| This function returns the full user name (something like "Mr. John Smith"). More...
bool | wxGetUserName (char *buf, int sz)
wxString | wxGetOsDescription ()
| Returns the string containing the description of the current platform in a user-readable form. More...
wxOperatingSystemId | wxGetOsVersion (int *major=NULL, int *minor=NULL, int *micro=NULL)
| Gets the version and the operating system ID for currently running OS. More...
bool | wxCheckOsVersion (int majorVsn, int minorVsn=0, int microVsn=0)
| Returns true if the version of the operating system on which the program is running under is the same or later than the given version. More...
bool | wxIsPlatform64Bit ()
| Returns true if the operating system the program is running under is 64 bit. More...
bool | wxIsPlatformLittleEndian ()
| Returns true if the current platform is little endian (instead of big endian). More...
wxString | wxGetCpuArchitectureName ()
| Returns the CPU architecture name. More...
wxString | wxGetNativeCpuArchitectureName ()
| In some situations the current process and native CPU architecture may be different. More...
wxLinuxDistributionInfo | wxGetLinuxDistributionInfo ()
| Returns a structure containing information about the currently running Linux distribution. More...

## Function Documentation

## ◆ wxCheckOsVersion()

bool wxCheckOsVersion | ( | int | majorVsn,
|  | int | minorVsn = `0`,
|  | int | microVsn = `0`
| ) |  |

Returns true if the version of the operating system on which the program is running under is the same or later than the given version.

Since
  3.1.0

See also
  wxGetOsVersion(), wxPlatformInfo

Include file:

    #include <wx/utils.h>

## ◆ wxGetCpuArchitectureName()

wxString wxGetCpuArchitectureName | ( |  | ) |

Returns the CPU architecture name.

This can be, for example, "x86_64", "arm64", or "i86pc". The name for the same CPU running on the same hardware can vary across operating systems.

The returned string may be empty if the CPU architecture couldn't be recognized.

See also
  wxGetNativeCpuArchitectureName()

Since
  3.1.5

## ◆ wxGetEmailAddress() [1/2]

wxString wxGetEmailAddress | ( |  | ) |

Copies the user's email address into the supplied buffer, by concatenating the values returned by wxGetFullHostName() and wxGetUserId().

Returns
  true if successful, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxGetEmailAddress() [2/2]

bool wxGetEmailAddress | ( | char * | buf,
|  | int | sz
| ) |  |

Deprecated:
  Use wxGetEmailAddress() instead.

Parameters

  buf | Buffer to store the email address in.
  sz | Size of the buffer.

Returns
  true if successful, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxGetFreeMemory()

wxMemorySize wxGetFreeMemory | ( |  | ) |

Returns the amount of free memory in bytes under environments which support it, and -1 if not supported or failed to perform measurement.

Include file:

    #include <wx/utils.h>

## ◆ wxGetFullHostName()

wxString wxGetFullHostName | ( |  | ) |

Returns the FQDN (fully qualified domain host name) or an empty string on error.

See also
  wxGetHostName()

Include file:

    #include <wx/utils.h>

## ◆ wxGetHomeDir()

wxString wxGetHomeDir | ( |  | ) |

Return the (current) user's home directory.

See also
  wxGetUserHome(), wxStandardPaths

Include file:

    #include <wx/utils.h>

## ◆ wxGetHostName() [1/2]

wxString wxGetHostName | ( |  | ) |

Copies the current host machine's name into the supplied buffer.

Please note that the returned name is not fully qualified, i.e. it does not include the domain name.

Returns
  The hostname if successful or an empty string otherwise.

See also
  wxGetFullHostName()

Include file:

    #include <wx/utils.h>

## ◆ wxGetHostName() [2/2]

bool wxGetHostName | ( | char * | buf,
|  | int | sz
| ) |  |

Deprecated:
  Use wxGetHostName() instead.

Parameters

  buf | Buffer to store the host name in.
  sz | Size of the buffer.

Returns
  true if successful, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxGetLinuxDistributionInfo()

wxLinuxDistributionInfo wxGetLinuxDistributionInfo | ( |  | ) |

Returns a structure containing information about the currently running Linux distribution.

This function uses the `lsb_release` utility which is part of the `Linux Standard Base Core` specification (see http://refspecs.linux-foundation.org/lsb.shtml) since the very first LSB release 1.0 (released in 2001). The `lsb_release` utility is very common on modern Linux distributions but in case it's not available, then this function will return a wxLinuxDistributionInfo structure containing empty strings.

This function is Linux-specific and is only available when the `__LINUX__` symbol is defined.

## ◆ wxGetNativeCpuArchitectureName()

wxString wxGetNativeCpuArchitectureName | ( |  | ) |

In some situations the current process and native CPU architecture may be different.

This returns the native CPU architecture regardless of the current process CPU architecture.

Common examples for CPU architecture differences are the following:

- Win32 process in x64 Windows (WoW)
- Win32 or x64 process on ARM64 Windows (WoW64)
- x86_64 process on ARM64 macOS (Rosetta 2)

The returned string may be empty if the CPU architecture couldn't be recognized.

See also
  wxGetCpuArchitectureName()

Since
  3.1.6

## ◆ wxGetOsDescription()

wxString wxGetOsDescription | ( |  | ) |

Returns the string containing the description of the current platform in a user-readable form.

For example, this function may return strings like "Windows 10 (build 10240), 64-bit edition" or "Linux 4.1.4 i386".

See also
  wxGetOsVersion()

Include file:

    #include <wx/utils.h>

## ◆ wxGetOsVersion()

wxOperatingSystemId wxGetOsVersion | ( | int * | major = `NULL`,
|  | int * | minor = `NULL`,
|  | int * | micro = `NULL`
| ) |  |

Gets the version and the operating system ID for currently running OS.

The returned wxOperatingSystemId value can be used for a basic categorization of the OS family; the major, minor, and micro version numbers allows detecting a specific system.

If on Unix-like systems the version can't be detected all three version numbers will have a value of -1.

On systems where only the micro version can't be detected or doesn't make sense, it will have a value of 0.

For Unix-like systems (`wxOS_UNIX`) the major, minor, and micro version integers will contain the kernel's major, minor, and micro version numbers (as returned by the 'uname -r' command); e.g. "4", "1", and "4" if the machine is using kernel 4.1.4.

For macOS systems (`wxOS_MAC`) the major and minor version integers are the natural version numbers associated with the OS; e.g. "10", "11" and "2" if the machine is using macOS El Capitan 10.11.2.

For Windows-like systems (`wxOS_WINDOWS`) the major, minor and micro (equal to the build number) version integers will contain the following values:

Windows OS name | Major version | Minor version | Build number
--- | --- | --- | ---
Windows 11 | 10 | 0 | >= 22000
Windows Server 2022 | 10 | 0 | >= 22000
Windows 10 | 10 | 0 |
Windows Server 2016 | 10 | 0 |
Windows 8.1 | 6 | 3 |
Windows Server 2012 R2 | 6 | 3 |
Windows 8 | 6 | 2 |
Windows Server 2012 | 6 | 2 |
Windows 7 | 6 | 1 |
Windows 2008 R2 | 6 | 1 |
Windows Vista | 6 | 0 |
Windows Server 2008 | 6 | 0 |
Windows Server 2003 R2 | 5 | 2 |
Windows Server 2003 | 5 | 2 |
Windows XP | 5 | 1 |

See the MSDN for more info about the values above.

See also
  wxGetOsDescription(), wxPlatformInfo

Include file:

    #include <wx/utils.h>

## ◆ wxGetUserHome()

wxString wxGetUserHome | ( | const wxString & | user = `wxEmptyString` | ) |

Returns the home directory for the given user.

If the user is empty (default value), this function behaves like wxGetHomeDir() (i.e. returns the current user home directory).

If the home directory couldn't be determined, an empty string is returned.

Include file:

    #include <wx/utils.h>

## ◆ wxGetUserId() [1/2]

wxString wxGetUserId | ( |  | ) |

This function returns the "user id" also known as "login name" under Unix (i.e.

something like "jsmith"). It uniquely identifies the current user (on this system). Under Windows or NT, this function first looks in the environment variables USER and LOGNAME; if neither of these is found, the entry UserId in the wxWidgets section of the WIN.INI file is tried.

Returns
  The login name if successful or an empty string otherwise.

See also
  wxGetUserName()

Include file:

    #include <wx/utils.h>

## ◆ wxGetUserId() [2/2]

bool wxGetUserId | ( | char * | buf,
|  | int | sz
| ) |  |

Deprecated:
  Use wxGetUserId() instead.

Parameters

  buf | Buffer to store the login name in.
  sz | Size of the buffer.

Returns
  true if successful, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxGetUserName() [1/2]

wxString wxGetUserName | ( |  | ) |

This function returns the full user name (something like "Mr. John Smith").

Under Windows or NT, this function looks for the entry UserName in the wxWidgets section of the WIN.INI file. If PenWindows is running, the entry Current in the section User of the PENWIN.INI file is used.

Returns
  The full user name if successful or an empty string otherwise.

See also
  wxGetUserId()

Include file:

    #include <wx/utils.h>

## ◆ wxGetUserName() [2/2]

bool wxGetUserName | ( | char * | buf,
|  | int | sz
| ) |  |

Deprecated:
  Use wxGetUserName() instead.

Parameters

  buf | Buffer to store the full user name in.
  sz | Size of the buffer.

Returns
  true if successful, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxIsPlatform64Bit()

bool wxIsPlatform64Bit | ( |  | ) |

Returns true if the operating system the program is running under is 64 bit.

The check is performed at run-time and may differ from the value available at compile-time (at compile-time you can just check if `sizeof(void*) == 8`) since the program could be running in emulation mode or in a mixed 32/64 bit system.

Note
  This function is not 100% reliable on some systems given the fact that there isn't always a standard way to do a reliable check on the OS bitness.

Include file:

    #include <wx/utils.h>

## ◆ wxIsPlatformLittleEndian()

bool wxIsPlatformLittleEndian | ( |  | ) |

Returns true if the current platform is little endian (instead of big endian).

The check is performed at run-time.

See also
  Byte Order Functions and Macros

Include file:

    #include <wx/utils.h>