Getting the Windows, System, Temp, & Current Directories
How do you get the Windows, System, Temp, or Current directory? Call GetDirectory() with any one of the DirectoryType. Example: WindowsSystemDirStr := GetDirectory(_SYSTEM); type DirectoryType = (_WINDOWS, _TEMP, _SYSTEM, _CURRENT);
functionGetDirectory(Dir: DirectoryType): string; var Path: array [0..260] of Char; begin
FillChar(Path, SizeOf(Path), #0); case Dir of _WINDOWS: GetWindowsDirectory(Path, Sizeof(Path)); _SYSTEM : GetSystemDirectory(Path, Sizeof(Path)); _TEMP : GetTempPath(Sizeof(Path), Path); _CURRENT: GetCurrentDirectory(Sizeof(Path), Path); end; Result := StrPas(Path); end;