function GetExePath: string;
begin
Result := ExtractFilePath(ParamStr());
end; function GetTempFileName: string;
var
vPath: string;
begin
SetLength(Result, );
GetTempFileName(PChar(GetExePath), PChar('~'), , PChar(result)); vPath := GetExePath + 'temp\';
if not SysUtils.DirectoryExists(vPath) then
SysUtils.ForceDirectories(vPath);
result := PChar(Result); //去掉多余的空字符
Result := vPath + ExtractFileName(Result);
end;
http://blog.****.net/shuaihj/article/details/7108792