//譬如 WINDIR 是表示系統目錄的系統變量, 可以這樣獲取:
var
s: string;
begin
s := GetEnvironmentVariable('WINDIR');
ShowMessage(s); {C:\WINDOWS}
end;
(*--------------------------------------------------------------------------------
WINDIR {系統目錄 - C:\WINDOWS}
SYSTEMROOT {系統目錄 - C:\WINDOWS}
SYSTEMDRIVE {系統根目錄 - C:}
HOMEDRIVE {當前用戶根目錄 - C:}
USERPROFILE {當前用戶目錄 - C:\Documents and Settings\wy}
HOMEPATH {當前用戶路徑 - \Documents and Settings\wy}
TMP {當前用戶臨時文件夾 - C:\DOCUME~1\wy\LOCALS~1\Temp}
TEMP {當前用戶臨時文件夾 - C:\DOCUME~1\wy\LOCALS~1\Temp}
APPDATA {當前用戶數據文件夾 - C:\Documents and Settings\wy\Application Data}
PROGRAMFILES {程序默認安裝目錄 - C:\Program Files}
COMMONPROGRAMFILES {文件通用目錄 - C:\Program Files\Common Files}
USERNAME {當前用戶名 - wy}
ALLUSERSPROFILE {所有用戶文件目錄 - C:\Documents and Settings\All Users}
OS {操作系統名 - Windows_NT}
COMPUTERNAME {計算機名 - IBM-B63851E95C9}
NUMBER_OF_PROCESSORS {處理器個數 - 1}
PROCESSOR_ARCHITECTURE {處理器芯片架構 - x86}
PROCESSOR_LEVEL {處理器型號 - 6}
PROCESSOR_REVISION {處理器修訂號 - 0905}
USERDOMAIN {包含用戶帳號的域 - IBM-B63851E95C9}
COMSPEC {C:\WINDOWS\system32\cmd.exe}
PATHEXT {執行文件類型 - .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.pyo;.pyc;.py;.pyw}
Path {搜索路徑} s: string;
--------------------------------------------------------------------------------*)
begin
s := GetCurrentDir;
ShowMessage(s); {C:\Documents and Settings\wy\My Documents\RAD Studio\Projects}
SetCurrentDir('..');
s := GetCurrentDir;
ShowMessage(s); {C:\Documents and Settings\wy\My Documents\RAD Studio}
SetCurrentDir('..\..');
s := GetCurrentDir;
ShowMessage(s); {C:\Documents and Settings\wy}
end;