添加 USE ShlObj,
function GetWinDir(Path: Integer): string;
var
Pid: PItemIDList;
sPath: array[0..255] of char;
begin
try
SHGetSpecialFolderLocation(Application.Handle, Path, Pid);
if SHGetPathFromIDList(Pid, sPath) then
{如果文件夹不是系统的一部分就返回False}
result := StrPas(sPath);
except
ShowMessage('定位路径有误, 请再试!');
end;
end;
利用GetWindir(CSIDL_INTERNET_CACHE)即可得到缓存路径;
PID具体参数请参见ShlObj.PAS