Environment Environment Environment Environment Class

정의

현재 환경 및 플랫폼에 대한 정보 및 조작 방법을 제공합니다.Provides information about, and means to manipulate, the current environment and platform. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.

public ref class Environment abstract sealed
[System.Runtime.InteropServices.ComVisible(true)]
public static class Environment
type Environment = class
Public Class Environment
상속
EnvironmentEnvironmentEnvironmentEnvironment
특성

예제

다음 예에서는 현재 환경에 대 한 정보 목록을 표시 하는 방법을 보여 줍니다.The following example demonstrates displays a list of information about the current environment.

// Sample for Environment class summary
using namespace System;
using namespace System::Collections;
int main()
{
   String^ str;
   String^ nl = Environment::NewLine;
   
   //
   Console::WriteLine();
   Console::WriteLine( "-- Environment members --" );
   
   //  Invoke this sample with an arbitrary set of command line arguments.
   Console::WriteLine( "CommandLine: {0}", Environment::CommandLine );
   array<String^>^arguments = Environment::GetCommandLineArgs();
   Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ", ", arguments ) );
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "CurrentDirectory: {0}", Environment::CurrentDirectory );
   Console::WriteLine( "ExitCode: {0}", Environment::ExitCode );
   Console::WriteLine( "HasShutdownStarted: {0}", Environment::HasShutdownStarted );
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "MachineName: {0}", Environment::MachineName );
   Console::WriteLine( "NewLine: {0}  first line {0}  second line {0}  third line", Environment::NewLine );
   Console::WriteLine( "OSVersion: {0}", Environment::OSVersion );
   Console::WriteLine( "StackTrace: ' {0}'", Environment::StackTrace );
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "SystemDirectory: {0}", Environment::SystemDirectory );
   Console::WriteLine( "TickCount: {0}", Environment::TickCount );
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "UserDomainName: {0}", Environment::UserDomainName );
   Console::WriteLine( "UserInteractive: {0}", Environment::UserInteractive );
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "UserName: {0}", Environment::UserName );
   Console::WriteLine( "Version: {0}", Environment::Version );
   Console::WriteLine( "WorkingSet: {0}", Environment::WorkingSet );
   
   //  No example for Exit(exitCode) because doing so would terminate this example.
   //  <-- Keep this information secure! -->
   String^ query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
   str = Environment::ExpandEnvironmentVariables( query );
   Console::WriteLine( "ExpandEnvironmentVariables: {0} {1}", nl, str );
   Console::WriteLine( "GetEnvironmentVariable: {0}  My temporary directory is {1}.", nl, Environment::GetEnvironmentVariable( "TEMP" ) );
   Console::WriteLine( "GetEnvironmentVariables: " );
   IDictionary^ environmentVariables = Environment::GetEnvironmentVariables();
   IEnumerator^ myEnum = environmentVariables->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      DictionaryEntry^ de = safe_cast<DictionaryEntry^>(myEnum->Current);
      Console::WriteLine( " {0} = {1}", de->Key, de->Value );
   }

   Console::WriteLine( "GetFolderPath: {0}", Environment::GetFolderPath( Environment::SpecialFolder::System ) );
   array<String^>^drives = Environment::GetLogicalDrives();
   Console::WriteLine( "GetLogicalDrives: {0}", String::Join( ", ", drives ) );
}

/*
This example produces results similar to the following:
(Any result that is lengthy or reveals information that should remain 
secure has been omitted and marked S"!---OMITTED---!".)

C:\>env0 ARBITRARY TEXT

-- Environment members --
CommandLine: env0 ARBITRARY TEXT
GetCommandLineArgs: env0, ARBITRARY, TEXT
CurrentDirectory: C:\Documents and Settings\!---OMITTED---!
ExitCode: 0
HasShutdownStarted: False
MachineName: !---OMITTED---!
NewLine:
  first line
  second line
  third line
OSVersion: Microsoft Windows NT 5.1.2600.0
StackTrace: '   at System::Environment::GetStackTrace(Exception e)
   at System::Environment::GetStackTrace(Exception e)
   at System::Environment::get_StackTrace()
   at Sample::Main()'
SystemDirectory: C:\WINNT\System32
TickCount: 17995355
UserDomainName: !---OMITTED---!
UserInteractive: True
UserName: !---OMITTED---!
Version: !---OMITTED---!
WorkingSet: 5038080
ExpandEnvironmentVariables:
  My system drive is C: and my system root is C:\WINNT
GetEnvironmentVariable:
  My temporary directory is C:\DOCUME~1\!---OMITTED---!\LOCALS~1\Temp.
GetEnvironmentVariables:
  !---OMITTED---!
GetFolderPath: C:\WINNT\System32
GetLogicalDrives: A:\, C:\, D:\

*/
// Sample for Environment class summary
using System;
using System.Collections;

class Sample
{
    public static void Main()
    {
        string str;
        string nl = Environment.NewLine;
        //
        Console.WriteLine();
        Console.WriteLine("-- Environment members --");

        //  Invoke this sample with an arbitrary set of command line arguments.
        Console.WriteLine("CommandLine: {0}", Environment.CommandLine);

        string[] arguments = Environment.GetCommandLineArgs();
        Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", arguments));

        //  <-- Keep this information secure! -->
        Console.WriteLine("CurrentDirectory: {0}", Environment.CurrentDirectory);

        Console.WriteLine("ExitCode: {0}", Environment.ExitCode);

        Console.WriteLine("HasShutdownStarted: {0}", Environment.HasShutdownStarted);

        //  <-- Keep this information secure! -->
        Console.WriteLine("MachineName: {0}", Environment.MachineName);

        Console.WriteLine("NewLine: {0}  first line{0}  second line{0}  third line",
                              Environment.NewLine);

        Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString());

        Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);

        //  <-- Keep this information secure! -->
        Console.WriteLine("SystemDirectory: {0}", Environment.SystemDirectory);

        Console.WriteLine("TickCount: {0}", Environment.TickCount);

        //  <-- Keep this information secure! -->
        Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);

        Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);

        //  <-- Keep this information secure! -->
        Console.WriteLine("UserName: {0}", Environment.UserName);

        Console.WriteLine("Version: {0}", Environment.Version.ToString());

        Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet);

        //  No example for Exit(exitCode) because doing so would terminate this example.

        //  <-- Keep this information secure! -->
        string query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
        str = Environment.ExpandEnvironmentVariables(query);
        Console.WriteLine("ExpandEnvironmentVariables: {0}  {1}", nl, str);

        Console.WriteLine("GetEnvironmentVariable: {0}  My temporary directory is {1}.", nl,
                               Environment.GetEnvironmentVariable("TEMP"));

        Console.WriteLine("GetEnvironmentVariables: ");
        IDictionary environmentVariables = Environment.GetEnvironmentVariables();
        foreach (DictionaryEntry de in environmentVariables)
        {
            Console.WriteLine("  {0} = {1}", de.Key, de.Value);
        }

        Console.WriteLine("GetFolderPath: {0}",
                     Environment.GetFolderPath(Environment.SpecialFolder.System));

        string[] drives = Environment.GetLogicalDrives();
        Console.WriteLine("GetLogicalDrives: {0}", String.Join(", ", drives));
    }
}
/*
This example produces results similar to the following:
(Any result that is lengthy or reveals information that should remain 
secure has been omitted and marked "!---OMITTED---!".)

C:\>env0 ARBITRARY TEXT

-- Environment members --
CommandLine: env0 ARBITRARY TEXT
GetCommandLineArgs: env0, ARBITRARY, TEXT
CurrentDirectory: C:\Documents and Settings\!---OMITTED---!
ExitCode: 0
HasShutdownStarted: False
MachineName: !---OMITTED---!
NewLine:
  first line
  second line
  third line
OSVersion: Microsoft Windows NT 5.1.2600.0
StackTrace: '   at System.Environment.GetStackTrace(Exception e)
   at System.Environment.GetStackTrace(Exception e)
   at System.Environment.get_StackTrace()
   at Sample.Main()'
SystemDirectory: C:\WINNT\System32
TickCount: 17995355
UserDomainName: !---OMITTED---!
UserInteractive: True
UserName: !---OMITTED---!
Version: !---OMITTED---!
WorkingSet: 5038080
ExpandEnvironmentVariables:
  My system drive is C: and my system root is C:\WINNT
GetEnvironmentVariable:
  My temporary directory is C:\DOCUME~1\!---OMITTED---!\LOCALS~1\Temp.
GetEnvironmentVariables: 
  !---OMITTED---!
GetFolderPath: C:\WINNT\System32
GetLogicalDrives: A:\, C:\, D:\

*/
' Sample for Environment class summary
Imports System
Imports System.Collections

Class Sample
   Public Shared Sub Main()
      Dim str As [String]
      Dim nl As [String] = Environment.NewLine
      '
      Console.WriteLine()
      Console.WriteLine("-- Environment members --")
      
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
      
      Dim arguments As [String]() = Environment.GetCommandLineArgs()
      Console.WriteLine("GetCommandLineArgs: {0}", [String].Join(", ", arguments))
      
      '  <-- Keep this information secure! -->
      Console.WriteLine("CurrentDirectory: {0}", Environment.CurrentDirectory)
      
      Console.WriteLine("ExitCode: {0}", Environment.ExitCode)
      
      Console.WriteLine("HasShutdownStarted: {0}", Environment.HasShutdownStarted)
      
      '  <-- Keep this information secure! -->
      Console.WriteLine("MachineName: {0}", Environment.MachineName)
      
      Console.WriteLine("NewLine: {0}  first line{0}  second line{0}" & _
                        "  third line", Environment.NewLine)
      
      Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString())
      
      Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace)
      
      '  <-- Keep this information secure! -->
      Console.WriteLine("SystemDirectory: {0}", Environment.SystemDirectory)
      
      Console.WriteLine("TickCount: {0}", Environment.TickCount)
      
      '  <-- Keep this information secure! -->
      Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName)
      
      Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive)
      
      '  <-- Keep this information secure! -->
      Console.WriteLine("UserName: {0}", Environment.UserName)
      
      Console.WriteLine("Version: {0}", Environment.Version.ToString())
      
      Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet)
      
      '  No example for Exit(exitCode) because doing so would terminate this example.

      '  <-- Keep this information secure! -->
      Dim query As [String] = "My system drive is %SystemDrive% and my" & _
                              " system root is %SystemRoot%"
      str = Environment.ExpandEnvironmentVariables(query)
      Console.WriteLine("ExpandEnvironmentVariables: {0}  {1}", nl, str)
      
      Console.WriteLine("GetEnvironmentVariable: {0}  My temporary directory is {1}.", _
                        nl, Environment.GetEnvironmentVariable("TEMP"))
      
      Console.WriteLine("GetEnvironmentVariables: ")
      Dim environmentVariables As IDictionary = Environment.GetEnvironmentVariables()
      Dim de As DictionaryEntry
      For Each de In environmentVariables
         Console.WriteLine("  {0} = {1}", de.Key, de.Value)
      Next de
      
      Console.WriteLine("GetFolderPath: {0}", _
              Environment.GetFolderPath(Environment.SpecialFolder.System))
      
      Dim drives As [String]() = Environment.GetLogicalDrives()
      Console.WriteLine("GetLogicalDrives: {0}", [String].Join(", ", drives))
   End Sub 'Main
End Class 'Sample
'
'This example produces results similar to the following:
'(Any result that is lengthy or reveals information that should remain 
'secure has been omitted and marked "!---OMITTED---!".)
'
'C:\>env0 ARBITRARY TEXT
'
'-- Environment members --
'CommandLine: env0 ARBITRARY TEXT
'GetCommandLineArgs: env0, ARBITRARY, TEXT
'CurrentDirectory: C:\Documents and Settings\!---OMITTED---!
'ExitCode: 0
'HasShutdownStarted: False
'MachineName: !---OMITTED---!
'NewLine:
'  first line
'  second line
'  third line
'OSVersion: Microsoft Windows NT 5.1.2600.0
'StackTrace: '   at System.Environment.GetStackTrace(Exception e)
'   at System.Environment.GetStackTrace(Exception e)
'   at System.Environment.get_StackTrace()
'   at Sample.Main()'
'SystemDirectory: C:\WINNT\System32
'TickCount: 17995355
'UserDomainName: !---OMITTED---!
'UserInteractive: True
'UserName: !---OMITTED---!
'Version: !---OMITTED---!
'WorkingSet: 5038080
'ExpandEnvironmentVariables:
'  My system drive is C: and my system root is C:\WINNT
'GetEnvironmentVariable:
'  My temporary directory is C:\DOCUME~1\!---OMITTED---!\LOCALS~1\Temp.
'GetEnvironmentVariables: 
'  !---OMITTED---!
'GetFolderPath: C:\WINNT\System32
'GetLogicalDrives: A:\, C:\, D:\
'

설명

사용 된 Environment 마지막으로 시스템을 부팅 하 고 공용 언어 런타임의 버전 이후 명령줄 인수, 종료 코드, 환경 변수 설정, 시간, 호출 스택의 내용을 같은 정보를 검색 하는 클래스입니다.Use the Environment class to retrieve information such as command-line arguments, the exit code, environment variable settings, contents of the call stack, time since last system boot, and the version of the common language runtime.

속성

CommandLine CommandLine CommandLine CommandLine

이 프로세스에 대한 명령줄을 가져옵니다.Gets the command line for this process.

CurrentDirectory CurrentDirectory CurrentDirectory CurrentDirectory

현재 작업 디렉터리의 정규화된 경로를 가져오거나 설정합니다.Gets or sets the fully qualified path of the current working directory.

CurrentManagedThreadId CurrentManagedThreadId CurrentManagedThreadId CurrentManagedThreadId

현재 관리되는 스레드의 고유 식별자를 가져옵니다.Gets a unique identifier for the current managed thread.

ExitCode ExitCode ExitCode ExitCode

프로세스의 종료 코드를 가져오거나 설정합니다.Gets or sets the exit code of the process.

HasShutdownStarted HasShutdownStarted HasShutdownStarted HasShutdownStarted

현재 애플리케이션 도메인이 언로드되고 있는지 또는 CLR(공용 언어 런타임)이 종료되고 있는지를 나타내는 값을 가져옵니다.Gets a value that indicates whether the current application domain is being unloaded or the common language runtime (CLR) is shutting down.

Is64BitOperatingSystem Is64BitOperatingSystem Is64BitOperatingSystem Is64BitOperatingSystem

현재 운영 체제가 64비트 운영 체제인지를 확인합니다.Determines whether the current operating system is a 64-bit operating system.

Is64BitProcess Is64BitProcess Is64BitProcess Is64BitProcess

현재 프로세스가 64비트 프로세스인지를 확인합니다.Determines whether the current process is a 64-bit process.

MachineName MachineName MachineName MachineName

이 로컬 컴퓨터의 NetBIOS 이름을 가져옵니다.Gets the NetBIOS name of this local computer.

NewLine NewLine NewLine NewLine

이 환경에 대해 정의된 줄 바꿈 문자열을 가져옵니다.Gets the newline string defined for this environment.

OSVersion OSVersion OSVersion OSVersion

현재 플랫폼 식별자와 버전 번호가 들어 있는 OperatingSystem 개체를 가져옵니다.Gets an OperatingSystem object that contains the current platform identifier and version number.

ProcessorCount ProcessorCount ProcessorCount ProcessorCount

현재 컴퓨터의 프로세서 수를 가져옵니다.Gets the number of processors on the current machine.

StackTrace StackTrace StackTrace StackTrace

현재 스택 추적 정보를 가져옵니다.Gets current stack trace information.

SystemDirectory SystemDirectory SystemDirectory SystemDirectory

시스템 디렉터리의 정규화된 경로를 가져옵니다.Gets the fully qualified path of the system directory.

SystemPageSize SystemPageSize SystemPageSize SystemPageSize

운영 체제의 메모리 페이지에서 바이트 수를 가져옵니다.Gets the number of bytes in the operating system's memory page.

TickCount TickCount TickCount TickCount

시스템 시작 이후 경과 시간(밀리초)을 가져옵니다.Gets the number of milliseconds elapsed since the system started.

TickCount64 TickCount64 TickCount64 TickCount64
UserDomainName UserDomainName UserDomainName UserDomainName

현재 사용자와 관련된 네트워크 도메인 이름을 가져옵니다.Gets the network domain name associated with the current user.

UserInteractive UserInteractive UserInteractive UserInteractive

현재 프로세스가 사용자 대화형 모드로 실행되고 있는지를 나타내는 값을 가져옵니다.Gets a value indicating whether the current process is running in user interactive mode.

UserName UserName UserName UserName

운영 체제에 현재 로그온한 사용자의 이름을 가져옵니다.Gets the user name of the person who is currently logged on to the operating system.

Version Version Version Version

공용 언어 런타임의 주 번호, 보조 번호, 빌드 번호 및 수정 번호를 설명하는 Version 개체를 가져옵니다.Gets a Version object that describes the major, minor, build, and revision numbers of the common language runtime.

WorkingSet WorkingSet WorkingSet WorkingSet

프로세스 컨텍스트에 매핑되는 실제 메모리의 크기를 가져옵니다.Gets the amount of physical memory mapped to the process context.

메서드

Exit(Int32) Exit(Int32) Exit(Int32) Exit(Int32)

이 프로세스를 종료하고 운영 체제에 종료 코드를 반환합니다.Terminates this process and returns an exit code to the operating system.

ExpandEnvironmentVariables(String) ExpandEnvironmentVariables(String) ExpandEnvironmentVariables(String) ExpandEnvironmentVariables(String)

지정된 문자열에 있는 각 환경 변수 이름을 해당 변수의 값에 해당하는 문자열로 바꾼 다음 결과 문자열을 반환합니다.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.

FailFast(String) FailFast(String) FailFast(String) FailFast(String)

Windows 애플리케이션 이벤트 로그에 메시지를 쓴 후 프로세스를 즉시 종료한 다음 해당 메시지를 Microsoft로 보내는 오류 보고에 포함시킵니다.Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message in error reporting to Microsoft.

FailFast(String, Exception) FailFast(String, Exception) FailFast(String, Exception) FailFast(String, Exception)

Windows 애플리케이션 이벤트 로그에 메시지를 쓴 후 프로세스를 즉시 종료한 다음 해당 메시지와 예외 정보를 Microsoft로 보내는 오류 보고에 포함시킵니다.Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft.

GetCommandLineArgs() GetCommandLineArgs() GetCommandLineArgs() GetCommandLineArgs()

현재 프로세스에 대한 명령줄 인수가 포함된 문자열 배열을 반환합니다.Returns a string array containing the command-line arguments for the current process.

GetEnvironmentVariable(String) GetEnvironmentVariable(String) GetEnvironmentVariable(String) GetEnvironmentVariable(String)

현재 프로세스에서 환경 변수의 값을 검색합니다.Retrieves the value of an environment variable from the current process.

GetEnvironmentVariable(String, EnvironmentVariableTarget) GetEnvironmentVariable(String, EnvironmentVariableTarget) GetEnvironmentVariable(String, EnvironmentVariableTarget) GetEnvironmentVariable(String, EnvironmentVariableTarget)

현재 프로세스 또는 현재 사용자나 로컬 컴퓨터의 Windows 운영 체제 레지스트리 키에서 환경 변수의 값을 검색합니다.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.

GetEnvironmentVariables() GetEnvironmentVariables() GetEnvironmentVariables() GetEnvironmentVariables()

현재 프로세스에서 모든 환경 변수 이름과 해당 값을 검색합니다.Retrieves all environment variable names and their values from the current process.

GetEnvironmentVariables(EnvironmentVariableTarget) GetEnvironmentVariables(EnvironmentVariableTarget) GetEnvironmentVariables(EnvironmentVariableTarget) GetEnvironmentVariables(EnvironmentVariableTarget)

현재 프로세스 또는 현재 사용자나 로컬 컴퓨터의 Windows 운영 체제 레지스트리 키에서 모든 환경 변수 이름과 해당 값을 검색합니다.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.

GetFolderPath(Environment+SpecialFolder) GetFolderPath(Environment+SpecialFolder) GetFolderPath(Environment+SpecialFolder) GetFolderPath(Environment+SpecialFolder)

지정된 열거형으로 식별되는 시스템 특수 폴더의 경로를 가져옵니다.Gets the path to the system special folder that is identified by the specified enumeration.

GetFolderPath(Environment+SpecialFolder, Environment+SpecialFolderOption) GetFolderPath(Environment+SpecialFolder, Environment+SpecialFolderOption) GetFolderPath(Environment+SpecialFolder, Environment+SpecialFolderOption) GetFolderPath(Environment+SpecialFolder, Environment+SpecialFolderOption)

지정된 열거형으로 식별되는 시스템 특수 폴더에 대한 경로를 가져오고 특수 폴더에 액세스하는 데 지정한 옵션을 사용합니다.Gets the path to the system special folder that is identified by the specified enumeration, and uses a specified option for accessing special folders.

GetLogicalDrives() GetLogicalDrives() GetLogicalDrives() GetLogicalDrives()

현재 컴퓨터의 논리 드라이브 이름이 포함된 문자열의 배열을 반환합니다.Returns an array of string containing the names of the logical drives on the current computer.

SetEnvironmentVariable(String, String) SetEnvironmentVariable(String, String) SetEnvironmentVariable(String, String) SetEnvironmentVariable(String, String)

현재 프로세스에 저장되어 있는 환경 변수를 생성, 수정 또는 삭제합니다.Creates, modifies, or deletes an environment variable stored in the current process.

SetEnvironmentVariable(String, String, EnvironmentVariableTarget) SetEnvironmentVariable(String, String, EnvironmentVariableTarget) SetEnvironmentVariable(String, String, EnvironmentVariableTarget) SetEnvironmentVariable(String, String, EnvironmentVariableTarget)

현재 프로세스 또는 현재 사용자나 로컬 컴퓨터에 예약된 Windows 운영 체제 레지스트리 키에 저장되어 있는 환경 변수를 생성, 수정 또는 삭제합니다.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.

적용 대상