| Version: 3.2.8

Typedefs | Functions
Environment
Functions and Macros by Category

## Detailed Description

These functions allow access to get or change the values of environment variables in a portable way.

They are currently implemented under Win32 and POSIX-like systems (Unix).

Remember that these functions add/change/delete environment variables of the current process only. Child processes copy the environment variables of the parent, but do not share them (a wxSetEnv() in the parent process won't change the value returned by wxGetEnv() in the child process and vice versa).

For more advanced interprocess communication techniques see Interprocess Communication.

## Typedefs
typedef wxStringToStringHashMap | wxEnvVariableHashMap
| A map type containing environment variables names and values. More...

## Functions
wxChar * | wxGetenv (const wxString &var)
| This is a macro defined as `getenv()` or its wide char version in Unicode mode. More...
bool | wxGetEnv (const wxString &var, wxString *value)
| Returns the current value of the environment variable var in value. More...
bool | wxSetEnv (const wxString &var, const wxString &value)
| Sets the value of the environment variable var (adding it if necessary) to value. More...
bool | wxUnsetEnv (const wxString &var)
| Removes the variable var from the environment. More...
bool | wxGetEnvMap (wxEnvVariableHashMap *map)
| Fill a map with the complete content of current environment. More...

## Typedef Documentation

## ◆ wxEnvVariableHashMap

typedef wxStringToStringHashMap wxEnvVariableHashMap

A map type containing environment variables names and values.

This type is used with wxGetEnvMap() function and wxExecuteEnv structure optionally passed to wxExecute().

Since
  2.9.2

Include file:

    #include <wx/utils.h>

## Function Documentation

## ◆ wxGetenv()

wxChar* wxGetenv | ( | const wxString & | var | ) |

This is a macro defined as `getenv()` or its wide char version in Unicode mode.

Note that under Win32 it may not return correct value for the variables set with wxSetEnv(), use wxGetEnv() function instead.

Include file:

    #include <wx/utils.h>

## ◆ wxGetEnv()

bool wxGetEnv | ( | const wxString & | var,
|  | wxString * | value
| ) |  |

Returns the current value of the environment variable var in value.

value may be NULL if you just want to know if the variable exists and are not interested in its value.

Returns true if the variable exists, false otherwise.

Include file:

    #include <wx/utils.h>

## ◆ wxGetEnvMap()

bool wxGetEnvMap | ( | wxEnvVariableHashMap * | map | ) |

Fill a map with the complete content of current environment.

The map will contain the environment variable names as keys and their values as values.

Parameters

  map | The environment map to fill, must be non-NULL.

Returns
  true if environment was successfully retrieved or false otherwise.

Include file:

    #include <wx/utils.h>

Since
  2.9.2

## ◆ wxSetEnv()

bool wxSetEnv | ( | const wxString & | var,
|  | const wxString & | value
| ) |  |

Sets the value of the environment variable var (adding it if necessary) to value.

Notice that under Windows platforms the program may have two different environment blocks: the first one is that of a Windows process and is always present, but the CRT may maintain its own independent copy of the environment. wxSetEnv() will always update the first copy, which means that wxGetEnv(), which uses it directly, will always return the expected value after this call. But wxSetEnv() only updates the second copy for some compilers/CRT implementations (currently only MSVC and MinGW which uses the same MSVC CRT) and so using wxGetenv() (notice the difference in case) may not return the updated value.

Parameters

  var | The environment variable to be set, must not contain `'='` character.
  value | New value of the variable.

Returns
  true on success or false if changing the value failed.

See also
  wxUnsetEnv()

Include file:

    #include <wx/utils.h>

## ◆ wxUnsetEnv()

bool wxUnsetEnv | ( | const wxString & | var | ) |

Removes the variable var from the environment.

wxGetEnv() will return NULL after the call to this function.

Returns true on success.

Include file:

    #include <wx/utils.h>