Ver Mensaje Individual
  #3  
Antiguo 18-01-2008
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Esto lo he encontrado aqui

El directorio de Windows

Código Delphi [-]
uses SysUtils, Windows;

function GetWindowsDir: TFileName;
var
  WinDir: array [0..MAX_PATH-1] of char;
begin
  SetString(Result, WinDir, GetWindowsDirectory(WinDir, MAX_PATH));
  if Result = '' then
    raise Exception.Create(SysErrorMessage(GetLastError));
end;

El directorio de los archivos de sistema

Código Delphi [-]
function GetSystemDir: TFileName;
var
  SysDir: array [0..MAX_PATH-1] of char;
begin
  SetString(Result, SysDir, GetSystemDirectory(SysDir, MAX_PATH));
  if Result = '' then
    raise Exception.Create(SysErrorMessage(GetLastError));
end;

El directorio de los archivos de programa

Código Delphi [-]
function GetProgramFilesDir: TFileName;
begin
  Result := GetRegistryData(HKEY_LOCAL_MACHINE,
    '\Software\Microsoft\Windows\CurrentVersion',
    'ProgramFilesDir');  // o 'ProgramFilesPath'
end;

El directorio temporal

Este es el directorio donde las aplicaciones guardan archivos temporales. No debería usar para este propósito el directorio donde se encuentra su aplicación por dos razones: 1) Usar un directorio temporal común facilita a los usuarios el proceso de limpieza cuando quieren recuperar espacio no usado en el disco duro, y 2) En Windows NT el usuario (y consiguientemente también su aplicación) puede que no tenga suficientes permisos para crear archivos en el directorio donde está instalada la aplicación.

La siguiente función devuelve la ubicación del directorio temporal, e intenta crearlo si no existe.

Código Delphi [-]
function GetTempDir: TFileName;
var
  TmpDir: array [0..MAX_PATH-1] of char;
begin
  try
    SetString(Result, TmpDir, GetTempPath(MAX_PATH, TmpDir));
    if not DirectoryExists(Result) then
      if not CreateDirectory(PChar(Result), nil) then begin
        Result := IncludeTrailingBackslash(GetWindowsDir) + 'TEMP';
        if not DirectoryExists(Result) then
          if not CreateDirectory(Pointer(Result), nil) then begin
            Result := ExtractFileDrive(Result) + '\TEMP';
            if not DirectoryExists(Result) then
              if not CreateDirectory(Pointer(Result), nil) then begin
                Result := ExtractFileDrive(Result) + '\TMP';
                if not DirectoryExists(Result) then
                  if not CreateDirectory(Pointer(Result), nil) then begin
                    raise Exception.Create(SysErrorMessage(GetLastError));
                  end;
              end;
          end;
      end;
  except
    Result := '';
    raise;
  end;
end;
Responder Con Cita