Directories

ディレクトリ関係の関数を詰め込んだユニット。

unit Directories;

interface

uses
  Windows, SysUtils;

  function WindowsDirectory: string;
  function SystemDirectory: string;
  function TemporaryDirectory: string;
  function CurrentDirectory: string;
  function ChangeDirectory(const Path: string): Boolean;

implementation

function WindowsDirectory: string;
begin
  SetLength(Result, MAX_PATH + 1);
  GetWindowsDirectory(PChar(Result), MAX_PATH);
  SetLength(Result, StrLen(PChar(Result)));
end;

function SystemDirectory: string;
begin
  SetLength(Result, MAX_PATH + 1);
  GetSystemDirectory(PChar(Result), MAX_PATH);
  SetLength(Result, StrLen(PChar(Result)));
end;

function TemporaryDirectory: string;
begin
  SetLength(Result, MAX_PATH + 1);
  GetTempPath(MAX_PATH, PChar(Result));
  SetLength(Result, StrLen(PChar(Result)));
end;

function CurrentDirectory: string;
begin
  SetLength(Result, MAX_PATH + 1);
  GetCurrentDirectory(MAX_PATH, PChar(Result));
  SetLength(Result, StrLen(PChar(Result)));
end;

function ChangeDirectory(const Path: string): Boolean;
begin
  Result := SetCurrentDirectory(PChar(Path));
end;

end.

Return index page