// http://www.outofmemory.cn function ExpandEnvironment(const strValue: string): string; var chrResult: array[0..1023] of Char; wrdReturn: DWORD; begin wrdReturn := ExpandEnvironmentStrings(PChar(strValue), chrResult, 1024); if wrdReturn = 0 then Result := strValue else begin Result := Trim(chrResult); end; end;
使用范例 EditPath.Text := ExpandEnvironment('%systemroot%Temp'); 在windows下输入如下结果 C:WindowsTemp