ApplicationBase.GetEnvironmentVariable(String) 메서드

정의

지정된 환경 변수의 값을 반환합니다.

public:
 System::String ^ GetEnvironmentVariable(System::String ^ name);
public string GetEnvironmentVariable (string name);
member this.GetEnvironmentVariable : string -> string
Public Function GetEnvironmentVariable (name As String) As String

매개 변수

name
String

환경 변수의 이름이 들어 있는 String입니다.

반환

이름이 name인 환경 변수의 값이 들어 있는 String입니다.

예외

name이(가) Nothing인 경우

name으로 지정된 환경 변수가 없는 경우.

호출 코드에 Read 액세스 권한이 있는 EnvironmentPermission이 없는 경우

예제

이 예제에서는 My.Application.GetEnvironmentVariable 메서드를 가져오고 사용 가능한 경우 PATH 환경 변수의 값을 표시 합니다. 그렇지 않은 경우 PATH 환경 변수에 없다는 메시지가 표시 됩니다.

Private Sub TestGetEnvironmentVariable()
    Try
        MsgBox("PATH = " & My.Application.GetEnvironmentVariable("PATH"))
    Catch ex As System.ArgumentException
        MsgBox("Environment variable 'PATH' does not exist.")
    End Try
End Sub

설명

합니다 My.Application.GetEnvironmentVariable 이름 사용 하 여 환경 변수를 반환 하는 메서드 name합니다. 이 메서드는 비슷합니다 Environment.GetEnvironmentVariable(String)이 메서드는 환경 변수를 지정 하면 예외가 발생 한다는 점을 제외 하면, name 존재 하지 않습니다.

프로젝트 형식에 따라 가용성

프로젝트 형식 사용 가능
Windows Forms 애플리케이션
클래스 라이브러리
콘솔 애플리케이션
Windows Forms 컨트롤 라이브러리
웹 컨트롤 라이브러리 No
Windows 서비스
웹 사이트 No

적용 대상

추가 정보