Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get system environment variables using boost library?

I work on windows and MacOS, I would like to get environment variables. How to get system environment variables using boost library?

Are there equivalent to System.Environment.GetEnvironmentVariable() from .Net ?

like image 713
Arman Avatar asked Jan 13 '12 11:01

Arman


People also ask

How do I find system environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

Where are system environment variables stored?

Machine environment variables are stored or retrieved from the following registry location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment . Process environment variables are generated dynamically every time a user logs in to the device and are restricted to a single process.

What is the use of Boost library in C++?

Boost is a set of libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains 164 individual libraries (as of version 1.76).


2 Answers

There's no need for Boost. Use std::getenv from <cstdlib>, which is a standard C++ function.

like image 192
Fred Foo Avatar answered Oct 19 '22 04:10

Fred Foo


You probably want a plain c (and ++) getenv() function, it needs not to be boosted.

like image 4
Michael Krelin - hacker Avatar answered Oct 19 '22 05:10

Michael Krelin - hacker