是这个吧?但是没有太清楚的理解你的意思。<br>function ExpandEnvironment(const strValue: string): string;<br>var<br> chrResult: array[0..1023] of Char;<br> wrdReturn: DWORD;<br>begin<br> wrdReturn := ExpandEnvironmentStrings(PChar(strValue), chrResult, 1024);<br> if wrdReturn = 0 then<br> Result := strValue<br> else<br> begin<br> Result := Trim(chrResult);<br> end;<br>end;<br><br>{如下,获得在Windows 下临时目录}<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> Caption:= ExpandEnvironment('%Temp%');<br>end;