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

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

http://blog.csdn.net/shuaihj/article/details/7108792

posted @ 2016-04-01 17:52  findumars  Views(501)  Comments(0Edit  收藏  举报