ApplicationBase.GetEnvironmentVariable(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 환경 변수의 값을 반환합니다.
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 환경 변수의 이름을 포함하는 형식입니다.
반품
String 이름이 name있는 환경 변수의 값을 포함하는 값입니다.
예외
name은 Nothing입니다.
지정한 환경 변수가 name 없습니다.
호출 코드에는 EnvironmentPermissionRead 액세스 권한이 없습니다.
예제
이 예제에서는 메서드를 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 애플리케이션 | Yes |
| 클래스 라이브러리 | Yes |
| 콘솔 애플리케이션 | Yes |
| Windows Forms 컨트롤 라이브러리 | Yes |
| 웹 제어 라이브러리 | No |
| Windows 서비스 | Yes |
| 웹 사이트 | No |