得到一个临时的文件名称(使用GetTempFileName API函数)

时间:2025-03-09 17:06:32
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