xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
xtd::environment Class Referencefinal

#include <environment.h>

Definition

The environment class.

Namespace
xtd
Library
xtd.core

Inherits xtd::static_object.

Public Types

enum class  special_folder {
  desktop ,
  programs ,
  my_documents ,
  personal ,
  favorites ,
  startup ,
  recent ,
  send_to ,
  start_menu ,
  my_music ,
  my_videos ,
  desktop_directory ,
  my_computer ,
  network_shortcuts ,
  fonts ,
  templates ,
  common_start_menu ,
  common_programs ,
  common_startup ,
  common_desktop_directory ,
  application_data ,
  printer_shortcuts ,
  local_application_data ,
  internet_cache ,
  cookies ,
  history ,
  common_application_data ,
  windows ,
  system ,
  program_files ,
  my_pictures ,
  user_profile ,
  system_x86 ,
  program_files_x86 ,
  common_program_files ,
  common_program_files_x86 ,
  common_templates ,
  common_documents ,
  common_admin_tools ,
  admin_tools ,
  common_music ,
  common_pictures ,
  common_videos ,
  resources ,
  localized_resources ,
  common_oem_links ,
  cd_burning ,
  home
}
 Specifies enumerated constants used to retrieve directory paths to system special folders. More...
 
enum class  special_folder_option {
  none ,
  do_not_verify ,
  create
}
 Specifies options to use for getting the path to a special folder. More...
 

Static Public Member Functions

static xtd::ustring command_line ()
 Gets the command line for this process.
 
static xtd::compiler compiler_version ()
 Gets an cpp_standard object that contains the current c++ standard identifier and version number.
 
static xtd::cpp_language cpp_version ()
 Gets an cpp_standard object that contains the current c++ standard identifier and version number.
 
static xtd::ustring current_directory ()
 Gets the fully qualified path of the current working directory.
 
static void current_directory (const xtd::ustring &directory_name)
 Sets the fully qualified path of the current working directory.
 
static std::thread::id current_thread_id ()
 Gets a unique identifier for the current thread.
 
static void exit (int exit_code)
 Terminates this process and returns an exit code to the operating system.
 
static int exit_code ()
 Gets the exit code of the process.
 
static void exit_code (int value)
 Sets the exit code of the process.
 
static xtd::ustring expand_environment_variables (const xtd::ustring &name)
 Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string.
 
static xtd::collections::specialized::string_vector get_command_line_args ()
 Returns a string array containing the command-line arguments for the current process.
 
static xtd::ustring get_environment_variable (const xtd::ustring &variable)
 Retrieves the value of an environment variable from the current process.
 
static xtd::ustring get_environment_variable (const xtd::ustring &variable, environment_variable_target target)
 Retrieves the value of an environment variable from the current process or from the Windows operating system registry key for the current user or local machine.
 
static std::map< std::string, std::string > & get_environment_variables ()
 Retrieves all environment variable names and their values from the current process.
 
static std::map< std::string, std::string > & get_environment_variables (environment_variable_target target)
 Retrieves all environment variable names and their values from the current process, or from the Windows operating system registry key for the current user or local machine.
 
static xtd::ustring get_folder_path (environment::special_folder folder)
 Gets the path to the system special folder that is identified by the specified enumeration.
 
static xtd::ustring get_folder_path (environment::special_folder folder, environment::special_folder_option option)
 Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.
 
static xtd::collections::specialized::string_vector get_logical_drives ()
 Returns an array of string containing the names of the logical drives on the current computer.
 
static bool is_64_bit_operating_system ()
 Determines whether the current operating system is a 64-bit operating system.
 
static bool is_64_bit_process ()
 Determines whether the current process is a 64-bit process.
 
static xtd::ustring machine_name ()
 Gets the NetBIOS name of this local computer.
 
static xtd::ustring new_line ()
 Gets the newline string defined for this environment.
 
template<class Char , class Traits >
static std::basic_ostream< Char, Traits > & new_line (std::basic_ostream< Char, Traits > &os)
 Inserts a new-line character and flushes the stream.
 
static xtd::operating_system os_version ()
 Gets an operating_system object that contains the current platform identifier and version number.
 
static uint32_t processor_count ()
 Gets the number of processors on the current machine.
 
static xtd::processor processor_information ()
 Gets an operating_system object that contains the current platform identifier and version number.
 
static void set_environment_variable (const xtd::ustring &variable, const xtd::ustring &value)
 Creates, modifies, or deletes an environment variable stored in the current process.
 
static void set_environment_variable (const xtd::ustring &variable, const xtd::ustring &value, environment_variable_target target)
 Creates, modifies, or deletes an environment variable stored in the current process or in the Windows operating system registry key reserved for the current user or local machine.
 
static xtd::ustring stack_trace ()
 Gets current stack trace information.
 
static xtd::ustring system_directory ()
 Gets the fully qualified path of the system directory.
 
static size_t system_page_size ()
 Gets the number of bytes in the operating system's memory page.
 
static std::chrono::milliseconds tick_count ()
 Gets the number of milliseconds elapsed since the system started.
 
static xtd::ustring user_domain_name ()
 Gets the network domain name associated with the current user.
 
static bool user_interactive ()
 Gets a value indicating whether the current process is running in user interactive mode.
 
static xtd::ustring user_name ()
 Gets the user name of the person who is currently logged on to the operating system.
 
static xtd::version version ()
 Gets a version consisting of the major, minor, build, and revision numbers of the xtd framework.
 

Member Enumeration Documentation

◆ special_folder

Specifies enumerated constants used to retrieve directory paths to system special folders.

Remarks
The system special folders are folders such as Program Files, Programs, System, or Startup, which contain common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows.
The get_folder_path method returns the locations associated with this enumeration. The locations of these folders can have different values on different operating systems, the user can change some of the locations, and the locations are localized.
For more information about special folders, see the KNOWNFOLDERID constants in the Windows documentation.
The list below typically represents special folders by OS :
Name android iOS Linux macOS Windows
desktop /home/${User}/Desktop /Users/${User}/Desktop /home/${User}/Desktop /Users/${User}/Desktop C:\Users\${User}\Desktop
programs C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
my_documents /home/${User} /Users/${User} /home/${User} /Users/${User} C:\Users\${User}\Documents
personal /home/${User} /Users/${User} /home/${User} /Users/${User} C:\Users\${User}\Documents
favorites /Users/${User}/Library/Favorites /Users/${User}/Library/Favorites C:\Users\${User}\Favorites
startup C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
recent C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Recent
send_to C:\Users\${User}\AppData\Roaming\Microsoft\Windows\SendTo
start_menu C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Start Menu
my_music /home/${User}/Music /Users/${User}/Music /home/${User}/Music /Users/${User}/Music C:\Users\${User}\Music
my_videos /home/${User}/Videos /Users/${User}/Videos /home/${User}/Videos /Users/${User}/Videos C:\Users\${User}\Videos
desktop_directory /home/${User}/Desktop /Users/${User}/Desktop /home/${User}/Desktop /Users/${User}/Desktop C:\Users\${User}\Desktop
my_computer
network_shortcuts C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Network Shortcuts
fonts /home/${User}/.fonts /Users/${User}/Library/Fonts /home/${User}/.fonts /Users/${User}/Library/Fonts C:\Windows\Fonts
templates /home/${User}/Templates /Users/${User}/Templates /home/${User}/Templates /Users/${User}/Templates C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Templates
common_start_menu C:\ProgramData\Microsoft\Windows\Start Menu
common_programs C:\ProgramData\Microsoft\Windows\Start Menu\Programs
common_startup C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
common_desktop_directory C:\Users\Public\Desktop
application_data /home/${User}/.config /Users/${User}/.config /home/${User}/.config /Users/${User}/.config C:\Users\${User}\AppData\Roaming
printer_shortcuts C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
local_application_data /home/${User}/.local/share /Users/${User}/.local/share /home/${User}/.local/share /Users/${User}/.local/share C:\Users\${User}\AppData\Local
internet_cache /Users/${User}/Library/Caches /Users/${User}/Library/Caches C:\Users\${User}\AppData\Local\Microsoft\Windows\Temporary Internet Files
cookies C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Cookies
history C:\Users\${User}\AppData\Local\Microsoft\Windows\History
common_application_data /usr/share /usr/share /usr/share /usr/share C:\ProgramData
windows C:\Windows
system /System C:\Windows\system32
program_files /Applications /Applications C:\Program Files (x86)
my_pictures /home/${User}/Pictures /Users/${User}/Pictures /home/${User}/Pictures /Users/${User}/Pictures C:\Users\${User}\Pictures
user_profile /home/${User} /Users/${User} /home/${User} /Users/${User} C:\Users\${User}
system_x86 C:\Windows\SysWOW64
program_files_x86 C:\Program Files (x86)
common_program_files C:\Program Files (x86)\Common Files
common_program_files_x86 C:\Program Files (x86)\Common Files
common_templates /usr/share/templates /usr/share/templates /usr/share/templates /usr/share/templates C:\ProgramData\Microsoft\Windows\Templates
common_documents C:\Users\Public\Documents
common_admin_tools C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
admin_tools C:\Users\${User}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
common_music C:\Users\Public\Music
common_pictures C:\Users\Public\Pictures
common_videos C:\Users\Public\Videos
resources C:\Windows\resources
localized_resources
common_oem_links
cd_burning C:\Users\${User}\AppData\Local\Microsoft\Windows\Burn\Burn
  • ${User} represent the login user name.
See also
environment
Enumerator
desktop 

The logical Desktop rather than the physical file system location.

programs 

The directory that contains the user's program groups.

my_documents 

The My Documents folder. This member is equivalent to Personal.

personal 

The directory that serves as a common repository for documents. This member is equivalent to MyDocuments.

favorites 

The directory that serves as a common repository for the user's favorite items.

startup 

The directory that corresponds to the user's Startup program group. The system starts these programs whenever a user logs on or starts Windows NT or later, or starts Windows 98.

recent 

The directory that contains the user's most recently used documents.

send_to 

The directory that contains the Send To menu items.

start_menu 

The directory that contains the Start menu items.

my_music 

The My Music folder.

my_videos 

The file system directory that serves as a repository for videos that belong to a user.

desktop_directory 

The directory used to physically store file objects on the desktop. Do not confuse this directory with the desktop folder itself, which is a virtual folder.

my_computer 

The My Computer folder. The MyComputer constant always yields the empty string ("") because no path is defined for the My Computer folder.

network_shortcuts 

A file system directory that contains the link objects that may exist in the My Network Places virtual folder.

fonts 

A virtual folder that contains fonts.

templates 

The directory that serves as a common repository for document templates.

common_start_menu 

The file system directory that contains the programs and folders that appear on the Start menu for all users. This special folder is valid only for Windows NT systems.

common_programs 

A folder for components that are shared across applications. This special folder is valid only for Windows NT, Windows 2000, and Windows XP systems.

common_startup 

The file system directory that contains the programs that appear in the Startup folder for all users. This special folder is valid only for Windows NT systems.

common_desktop_directory 

The file system directory that contains files and folders that appear on the desktop for all users. This special folder is valid only for Windows NT systems.

application_data 

The directory that serves as a common repository for application-specific data for the current roaming user. A roaming user works on more than one computer on a network. A roaming user's profile is kept on a server on the network and is loaded onto a system when the user logs on.

printer_shortcuts 

The file system directory that contains the link objects that can exist in the Printers virtual folder.

local_application_data 

The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.

internet_cache 

The directory that serves as a common repository for temporary Internet files.

cookies 

The directory that serves as a common repository for Internet cookies.

history 

The directory that serves as a common repository for Internet history items.

common_application_data 

The directory that serves as a common repository for application-specific data that is used by all users.

windows 

The Windows directory or SYSROOT. This corresponds to the windir% or SYSTEMROOT% environment variables.

system 

The System directory.

program_files 

The program files directory.On a non-x86 system, passing ProgramFiles to the GetFolderPath method returns the path for non-x86 programs. To get the x86 program files directory on a non-x86 system, use the ProgramFilesX86 member.

my_pictures 

The My Pictures folder.

user_profile 

The user's profile folder. Applications should not create files or folders at this level; they should put their data under the locations referred to by ApplicationData.

system_x86 

The Windows System folder.

program_files_x86 

The Program Files folder On an x86 system, passing the ProgramFilesX86 member to the Environment.GetFolderPath method returns string.Empty; use the ProgramFiles member instead. You can determine whether Windows is a 32-bit operating system by calling the Environment.Is64BitOperatingSystem property.

common_program_files 

The directory for components that are shared across applications.To get the x86 common program files directory on a non-x86 system, use the ProgramFilesX86 member.

common_program_files_x86 

The Program Files folder.

common_templates 

The file system directory that contains the templates that are available to all users. This special folder is valid only for Windows NT systems.

common_documents 

The file system directory that contains documents that are common to all users. This special folder is valid for Windows NT systems, Windows 95, and Windows 98 systems with Shfolder.dll installed.

common_admin_tools 

The file system directory that contains administrative tools for all users of the computer.

admin_tools 

The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user.

common_music 

The file system directory that serves as a repository for music files common to all users.

common_pictures 

The file system directory that serves as a repository for image files common to all users.

common_videos 

The file system directory that serves as a repository for video files common to all users.

resources 

The file system directory that contains resource data.

localized_resources 

The file system directory that contains localized resource data.

common_oem_links 

This value is recognized in Windows Vista for backward compatibility, but the special folder itself is no longer used.

cd_burning 

The file system directory that acts as a staging area for files waiting to be written to a CD.

home 

The file system directory that contains home folder.

◆ special_folder_option

Specifies options to use for getting the path to a special folder.

Remarks
The System.Environment.SpecialFolderOption enumeration is used to define the precise behavior of the Environment.GetFolderPath method.
Enumerator
none 

The path to the folder is verified. If the folder exists, the path is returned. If the folder does not exist, an empty string is returned. This is the default behavior.

do_not_verify 

The path to the folder is returned without verifying whether the path exists. If the folder is located on a network, specifying this option can reduce lag time.

create 

The path to the folder is created if it does not already exist.

Member Function Documentation

◆ command_line()

static xtd::ustring xtd::environment::command_line ( )
inlinestatic

Gets the command line for this process.

Returns
A string containing command-line arguments.
Remarks
This method provides access to the program name and any arguments specified on the command line when the current process was started.
The program name can include path information, but is not required to do so. Use the get_command_line_args method to retrieve the command-line information parsed and stored in an array of strings.
The maximum size of the command-line buffer is not set to a specific number of characters; it varies depending on the operating system that is running on the computer.

◆ compiler_version()

static xtd::compiler xtd::environment::compiler_version ( )
inlinestatic

Gets an cpp_standard object that contains the current c++ standard identifier and version number.

Returns
An object that contains the c++ standard identifier and version number.

◆ cpp_version()

static xtd::cpp_language xtd::environment::cpp_version ( )
inlinestatic

Gets an cpp_standard object that contains the current c++ standard identifier and version number.

Returns
An object that contains the c++ standard identifier and version number.

◆ current_directory() [1/2]

static xtd::ustring xtd::environment::current_directory ( )
static

Gets the fully qualified path of the current working directory.

Returns
xtd::ustring A string containing a directory path.
Remarks
By definition, if this process starts in the root directory of a local or network drive, the value returned by this method is the drive name followed by a trailing slash (for example, "C:\"). If this process starts in a subdirectory, the value returned by this method is the drive and subdirectory path, without a trailing slash (for example, "C:\mySubDirectory").

◆ current_directory() [2/2]

static void xtd::environment::current_directory ( const xtd::ustring directory_name)
static

Sets the fully qualified path of the current working directory.

Parameters
directory_nameA string containing a directory path.

◆ current_thread_id()

static std::thread::id xtd::environment::current_thread_id ( )
inlinestatic

Gets a unique identifier for the current thread.

Returns
A std::thread::id that represents a unique identifier for this thread.

◆ exit()

static void xtd::environment::exit ( int  exit_code)
inlinestatic

Terminates this process and returns an exit code to the operating system.

Parameters
exit_codeThe exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully.
Remarks
For the exit_code parameter, use a non-zero number to indicate an error. In your application, you can define your own error codes in an enumeration, and return the appropriate error code based on the scenario. For example, return a value of 1 to indicate that the required file is not present, and a value of 2 to indicate that the file is in the wrong format.

◆ exit_code() [1/2]

static int xtd::environment::exit_code ( )
static

Gets the exit code of the process.

Returns
A 32-bit signed integer containing the exit code. The default value is 0 (zero), which indicates that the process completed successfully.
Remarks
If the main method returns void, you can use this property to set the exit code that will be returned to the calling environment. If Main does not return void, this property is ignored. The initial value of this property is zero.
Warning
The exit_code property is a signed 32-bit integer. To prevent the property from returning a negative exit code, you should not use values greater than or equal to 0x80000000.
Remarks
Use a non-zero number to indicate an error. In your application, you can define your own error codes in an enumeration, and return the appropriate error code based on the scenario. For example, return a value of 1 to indicate that the required file is not present and a value of 2 to indicate that the file is in the wrong format.

◆ exit_code() [2/2]

static void xtd::environment::exit_code ( int  value)
static

Sets the exit code of the process.

Parameters
valueA 32-bit signed integer containing the exit code. The default value is 0 (zero), which indicates that the process completed successfully.
Remarks
If the main method returns void, you can use this property to set the exit code that will be returned to the calling environment. If Main does not return void, this property is ignored. The initial value of this property is zero.
Warning
The exit_code property is a signed 32-bit integer. To prevent the property from returning a negative exit code, you should not use values greater than or equal to 0x80000000.
Remarks
Use a non-zero number to indicate an error. In your application, you can define your own error codes in an enumeration, and return the appropriate error code based on the scenario. For example, return a value of 1 to indicate that the required file is not present and a value of 2 to indicate that the file is in the wrong format.

◆ expand_environment_variables()

static xtd::ustring xtd::environment::expand_environment_variables ( const xtd::ustring name)
inlinestatic

Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string.

Parameters
nameA string containing the names of zero or more environment variables. Each environment variable is quoted with the percent sign character (%).
Returns
A string with each environment variable replaced by its value.
Remarks
Replacement only occurs for environment variables that are set. For example, suppose name is "MyENV = %MyENV%". If the environment variable, MyENV, is set to 42, this method returns "MyENV = 42". If MyENV is not set, no change occurs; this method returns "MyENV = %MyENV%".

◆ get_command_line_args()

static xtd::collections::specialized::string_vector xtd::environment::get_command_line_args ( )
static

Returns a string array containing the command-line arguments for the current process.

Returns
An array of string where each element contains a command-line argument. The first element is the executable file name, and the following zero or more elements contain the remaining command-line arguments.
Remarks
The first element in the array contains the file name of the executing program. If the file name is not available, the first element is equal to string empty "". The remaining elements contain any additional tokens entered on the command line.
The program file name can, but is not required to, include path information.
Command line arguments are delimited by spaces. You can use double quotation marks (") to include spaces within an argument. The single quotation mark ('), however, does not provide this functionality. @remarks If a double quotation mark follows two or an even number of backslashes, each proceeding backslash pair is replaced with one backslash and the double quotation mark is removed. If a double quotation mark follows an odd number of backslashes, including just one, each preceding pair is replaced with one backslash and the remaining backslash is removed; however, in this case the double quotation mark is not removed. @remarks The following table shows how command line arguments can be delimited, and assumes MyApp as the current executing application. <table class="markdownTable"> <tr class="markdownTableHead"> <th class="markdownTableHeadNone"> Input at the command line

Resulting command line arguments

MyApp alpha beta

MyApp, alpha, beta

MyApp "alpha with spaces" "beta with spaces"

MyApp, alpha with spaces, beta with spaces

MyApp 'alpha with spaces' beta

MyApp, 'alpha, with, spaces', beta

MyApp \\alpha \\"beta

MyApp, \\alpha, \beta

MyApp \\"alpha "beta

MyApp, \"alpha, "beta

Remarks
To obtain the command line as a single string, use the command_line method.

◆ get_environment_variable() [1/2]

static xtd::ustring xtd::environment::get_environment_variable ( const xtd::ustring variable)
inlinestatic

Retrieves the value of an environment variable from the current process.

Parameters
variableThe name of the environment variable.
Returns
xtd::ustring The value of the environment variable specified by variable, or empty "" if the environment variable is not found.
Remarks
The get_environment_variable(xtd::ustring) method retrieves an environment variable from the environment block of the current process only. It is equivalent to calling the get_environment_variable(xtd::ustring, xtd::environment_variable_target) method with a target value of xtd::environment_variable_target.process.
To retrieve all environment variables along with their values, call the get_environment_variables method.
Environment variable names are case-sensitive on Linux and macOS but are not case-sensitive on Windows.

◆ get_environment_variable() [2/2]

static xtd::ustring xtd::environment::get_environment_variable ( const xtd::ustring variable,
environment_variable_target  target 
)
static

Retrieves the value of an environment variable from the current process or from the Windows operating system registry key for the current user or local machine.

Parameters
variableThe name of an environment variable.
targetOne of the EnvironmentVariableTarget values.
Exceptions
std::invalid_argumenttarget is not a valid environment_variable_target value.
Returns
xtd::ustring The value of the environment variable specified by the variable and target parameters, or empty "" if the environment variable is not found.
Remarks
To retrieve all environment variables along with their values, call the get_environment_variables method.
Environment variable names are case-sensitive on Linux and macOS but are not case-sensitive on Windows.
Todo:
Add xtd::registry and uncomment lines.

◆ get_environment_variables() [1/2]

static std::map< std::string, std::string > & xtd::environment::get_environment_variables ( )
inlinestatic

Retrieves all environment variable names and their values from the current process.

Returns
std::map A dictionary that contains all environment variable names and their values; otherwise, an empty dictionary if no environment variables are found.
Remarks
The names and values for the environment variables are stored as key-value pairs in the returned std::map.

◆ get_environment_variables() [2/2]

static std::map< std::string, std::string > & xtd::environment::get_environment_variables ( environment_variable_target  target)
static

Retrieves all environment variable names and their values from the current process, or from the Windows operating system registry key for the current user or local machine.

Parameters
targetOne of the environment_variable_target values.
Returns
std::map A dictionary that contains all environment variable names and their values from the source specified by the target parameter; otherwise, an empty dictionary if no environment variables are found.
Exceptions
std::invalid_argumenttarget is not a valid environment_variable_target value.
Remarks
The names and values for the environment variables are stored as key-value pairs in the returned std::map.
Todo:
Add xtd::registry and uncomment lines.

◆ get_folder_path() [1/2]

static xtd::ustring xtd::environment::get_folder_path ( environment::special_folder  folder)
inlinestatic

Gets the path to the system special folder that is identified by the specified enumeration.

Parameters
folderOne of enumeration values that identifies a system special folder.
Returns
The path to the specified system special folder, if that folder physically exists on your computer; otherwise, an empty string ("").
Remarks
This method retrieves the path to a system special folder, such as Program Files, Programs, System, or Startup, which can be used to access common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows.

◆ get_folder_path() [2/2]

static xtd::ustring xtd::environment::get_folder_path ( environment::special_folder  folder,
environment::special_folder_option  option 
)
static

Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.

Parameters
folderOne of the enumeration values that identifies a system special folder.
optionOne of the enumeration values that specifies options to use for accessing a special folder.
Returns
The path to the specified system special folder, if that folder physically exists on your computer; otherwise, an empty string ("").
Remarks
This method retrieves the path to a system special folder, such as Program Files, Programs, System, or Startup, which can be used to access common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows.
Todo:
Add xtd::io::directory and uncomment lines.

◆ get_logical_drives()

static xtd::collections::specialized::string_vector xtd::environment::get_logical_drives ( )
inlinestatic

Returns an array of string containing the names of the logical drives on the current computer.

Returns
An array of strings where each element contains the name of a logical drive. For example, if the computer's hard drive is the first logical drive, the first element returned is "C:\".
Todo:
Add xtd::io::__opaque_io and uncomment lines.

◆ is_64_bit_operating_system()

static bool xtd::environment::is_64_bit_operating_system ( )
inlinestatic

Determines whether the current operating system is a 64-bit operating system.

Returns
true if the operating system is 64-bit; otherwise, false.

◆ is_64_bit_process()

static bool xtd::environment::is_64_bit_process ( )
inlinestatic

Determines whether the current process is a 64-bit process.

Returns
true if the process is 64-bit; otherwise, false.

◆ machine_name()

static xtd::ustring xtd::environment::machine_name ( )
static

Gets the NetBIOS name of this local computer.

Returns
A string containing the name of this computer.
Remarks
The name of this computer is established at system startup when the name is read from the registry. If this computer is a node in a cluster, the name of the node is returned.

◆ new_line() [1/2]

static xtd::ustring xtd::environment::new_line ( )
static

Gets the newline string defined for this environment.

Returns
A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.

◆ new_line() [2/2]

template<class Char , class Traits >
static std::basic_ostream< Char, Traits > & xtd::environment::new_line ( std::basic_ostream< Char, Traits > &  os)
inlinestatic

Inserts a new-line character and flushes the stream.

Parameters
osOutput stream object affected. Because this function is a manipulator, it is designed to be used alone with no arguments in conjunction with the insertion (<<) operations on output streams (see example below).
Returns
Argument os.

◆ os_version()

static xtd::operating_system xtd::environment::os_version ( )
static

Gets an operating_system object that contains the current platform identifier and version number.

Returns
An object that contains the platform identifier and version number.

◆ processor_count()

static uint32_t xtd::environment::processor_count ( )
inlinestatic

Gets the number of processors on the current machine.

Returns
The 32-bit unsigned integer that specifies the number of processors on the current machine. There is no default. If the current machine contains multiple processor groups, this property returns the number of logical processors that are available for use.

◆ processor_information()

static xtd::processor xtd::environment::processor_information ( )
static

Gets an operating_system object that contains the current platform identifier and version number.

Returns
An object that contains the platform identifier and version number.

◆ set_environment_variable() [1/2]

static void xtd::environment::set_environment_variable ( const xtd::ustring variable,
const xtd::ustring value 
)
inlinestatic

Creates, modifies, or deletes an environment variable stored in the current process.

Parameters
variableThe name of an environment variable.
valueA value to assign to variable.
Remarks
Calling this method is equivalent to calling the set_environment_variable(xtd::ustring, xtd::ustring, environment_variable_target) overload with a value of environment_variable_target::process for the target argument.
If the value argument is not empty and the environment variable named by the variable parameter does not exist, the environment variable is created and assigned the contents of value. If it does exist, its value is modified. Because the environment variable is defined in the environment block of the current process only, it does not persist after the process has ended.
If value is empty and the environment variable named by variable exists, the environment variable is deleted. If variable does not exist, no error occurs even though the operation cannot be performed.

◆ set_environment_variable() [2/2]

static void xtd::environment::set_environment_variable ( const xtd::ustring variable,
const xtd::ustring value,
environment_variable_target  target 
)
static

Creates, modifies, or deletes an environment variable stored in the current process or in the Windows operating system registry key reserved for the current user or local machine.

Parameters
variableThe name of an environment variable.
valueA value to assign to variable.
Remarks
The set_environment_variable(xtd::ustring, xtd::ustring, environment_variable_target) method lets you define an environment variable that is available to the current process (the environment_variable_target::process value). Environment variables that are unique to the current process environment block persist only until the process ends.
In addition, on Windows systems only, the set_environment_variable(xtd::ustring, xtd::ustring, environment_variable_target) method lets you define an environment variable that is available to all processes that run on a machine (the environment_variable_target::machine value) and to all processes run by a user (the environment_variable_target::user value). Per-machine and per-user environment variables are copied into the environment block of the current process.
If the value argument is not empty and the environment variable named by the variable argument does not exist, the environment variable is created and assigned the contents of value. If it does exist, its value is modified.
If value is empty and the environment variable named by variable exists, the environment variable is deleted. If variable does not exist, no error occurs even though the operation cannot be performed.
Todo:
Add xtd::registry and uncomment lines.

◆ stack_trace()

static xtd::ustring xtd::environment::stack_trace ( )
inlinestatic

Gets current stack trace information.

Returns
A string containing stack trace information. This value can be empty "".

◆ system_directory()

static xtd::ustring xtd::environment::system_directory ( )
inlinestatic

Gets the fully qualified path of the system directory.

Returns
A string containing a directory path.
Remarks
An example of the value returned is the string "C:\Windows".

◆ system_page_size()

static size_t xtd::environment::system_page_size ( )
static

Gets the number of bytes in the operating system's memory page.

Returns
The number of bytes in the system memory page.

◆ tick_count()

static std::chrono::milliseconds xtd::environment::tick_count ( )
static

Gets the number of milliseconds elapsed since the system started.

Returns
A 32-bit unsigned integer containing the amount of time in milliseconds that has passed since the last time the computer was started.

◆ user_domain_name()

static xtd::ustring xtd::environment::user_domain_name ( )
static

Gets the network domain name associated with the current user.

Returns
The network domain name associated with the current user.

◆ user_interactive()

static bool xtd::environment::user_interactive ( )
inlinestatic

Gets a value indicating whether the current process is running in user interactive mode.

Returns
bool true if the current process is running in user interactive mode; otherwise, false.
Remarks
The user_interactive method reports false for a Os process or a service like IIS that runs without a user interface. If this property is false, do not display modal dialogs or message boxes because there is no graphical user interface for the user to interact with.
Return always true for now.
Todo:
check if process is an operating system process or service process...

◆ user_name()

static xtd::ustring xtd::environment::user_name ( )
static

Gets the user name of the person who is currently logged on to the operating system.

Returns
The user name of the person who is logged on to the operating system.

◆ version()

static xtd::version xtd::environment::version ( )
static

Gets a version consisting of the major, minor, build, and revision numbers of the xtd framework.

Returns
The version of the xtd framework.

The documentation for this class was generated from the following file: