[Delphi (Object Pascal)] Delphi 创建一个临时文件 →→→→→进入此内容的聊天室

来自 , 2021-03-15, 写在 Delphi (Object Pascal), 查看 152 次.
URL http://www.code666.cn/view/c54d2118
  1. function TempFileName(const Stub: string; const Create: Boolean): string;
  2. begin
  3.   // Get temporary folder
  4.   SetLength(Result, Windows.MAX_PATH);
  5.   Windows.GetTempPath(Windows.MAX_PATH, PChar(Result));
  6.   // Get unique temporary file name (it is created as side effect of this call)
  7.   if Windows.GetTempFileName(
  8.     PChar(Result), PChar(Stub), 0, PChar(Result)
  9.   ) <> 0 then
  10.   begin
  11.     // Succeeded
  12.     Result := PChar(Result);
  13.     if not Create then
  14.       // user doesn't want file creating: so we delete the file
  15.       SysUtils.DeleteFile(Result);
  16.   end
  17.   else
  18.     // Failed
  19.     Result := '';
  20. end;
  21. //delphi/2228

回复 "Delphi 创建一个临时文件"

这儿你可以回复上面这条便签

captcha