源:GetEnvironmentVariable 获取常用系统变量
//譬如 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 Settingswy} HOMEPATH {当户路径 - Documents and Settingswy} TMP {当户临时文夹 - C:DOCUME~1wyLOCALS~1Temp} TEMP {当户临时文夹 - C:DOCUME~1wyLOCALS~1Temp} APPDATA {当户数据文夹 - C:Documents and SettingswyApplication Data} PROGRAMFILES {程序默认安装目录 - C:Program Files} COMMONPROGRAMFILES {文通目录 - C:Program FilesCommon Files} USERNAME {当户名 - wy} ALLUSERSPROFILE {所有户文目录 - C:Documents and SettingsAll 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:WINDOWSsystem32cmd.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 SettingswyMy DocumentsRAD StudioProjects} SetCurrentDir('..'); s := GetCurrentDir; ShowMessage(s); {C:Documents and SettingswyMy DocumentsRAD Studio} SetCurrentDir('....'); s := GetCurrentDir; ShowMessage(s); {C:Documents and Settingswy} end;