Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Permisos en delphi (https://www.clubdelphi.com/foros/showthread.php?t=48123)

[Nora] 16-09-2007 16:06:22

Permisos en delphi
 
Hola a todos,

alguien sabe como se hace desde delphi 7 para comprobar los permisos de un fichero en windows xp?

Muchas gracias de antemano.:)

Un saludo!


egostar 16-09-2007 16:15:54

Hola Nora, bienvenida al club.

Puedes usar esto que está en la ayuda de Delphi

Código Delphi [-]
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  Attributes, NewAttributes: Word;
begin
  with FileAttrForm do
  begin
    FileDirName.Caption := FileList.Items[FileList.ItemIndex];
    { set box caption }
    PathName.Caption := FileList.Directory;
    { show directory name }
    ChangeDate.Caption := 
      DateTimeToStr(FileDateTime(FileList.FileName));
    Attributes := FileGetAttr(FileDirName.Caption);
    { read file attributes }
    ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
    Archive.Checked := (Attributes and faArchive) = faArchive;
    System.Checked := (Attributes and faSysFile) = faSysFile;
    Hidden.Checked := (Attributes and faHidden) = faHidden;
    if ShowModal <> id_Cancel then  { execute dialog box }
    begin
      NewAttributes := Attributes;
      { start with original attributes }
      if ReadOnly.Checked then
        NewAttributes := NewAttributes or faReadOnly
      else 
        NewAttributes := NewAttributes and not faReadOnly;
      if Archive.Checked then
        NewAttributes := NewAttributes or faArchive
      else 
        NewAttributes := NewAttributes and not faArchive;
      if System.Checked then 
        NewAttributes := NewAttributes or faSysFile
      else 
        NewAttributes := NewAttributes and not faSysFile;
      if Hidden.Checked then 
        NewAttributes := NewAttributes or faHidden
      else 
        NewAttributes := NewAttributes and not faHidden;
      if NewAttributes <> Attributes then { if anything changed... }
        FileSetAttr(FileDirName.Caption, NewAttributes);
         { ...write the new values }
    end;
  end;
end;

Salud OS

[Nora] 16-09-2007 16:32:43

Perfecto. Muchas gracias egostar.

Llevaba un rato mirando por la ayuda, pero no lo daba encontrado.
No debí haber salido ayer! :o

Saludos!

egostar 16-09-2007 16:37:10

Cita:

Empezado por [Nora] (Mensaje 231454)
Perfecto. Muchas gracias egostar.

Llevaba un rato mirando por la ayuda, pero no lo daba encontrado.
No debí haber salido ayer! :o

Saludos!

:D:D no te preocupes, yo diría mejor, no debi ponerme a trabajar en domingo,,,,:cool:

Salud OS


La franja horaria es GMT +2. Ahora son las 17:06:47.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi