En fin. El caso es que me gustaría comprender como delphi trata los ficheros via API-Windows.
He escrito el siguiente código al objeto de tratar el tipo
TByHandleFileInformation.
Según "Los Tomos de delphi: Núcleo del Api-Win32" ed. Danysoft 1999 viene definido de la siguiente forma:
TByHandleFileInformation = record
dwFileAttributes: DWORD;
ftCreationTime: TFileTime;
ftLastAccessTime: TfileTime;
ftLastWriteTime: TFileTime;
dwVolumeSerialNumber: DWORD;
nFileSizeHigh: DWORD;
nFileSizeLow: DWORD;
nNumberOfLinks: DWORD;
nFileIndexHigh: DWORD;
nFileIndexLow: DWORD;
end.
Pues bien, he escrito el siguiente código al objeto de comprobar el tipo:
procedure TForm1.Button3Click(Sender: TObject);
var
hfile: integer;
fileinfo: tbyhandlefileinformation;
tamaño1,tamaño2:dword;
begin
tamaño1:=0;
tamaño2:=0;
hfile:=CreateFile(PChar(ShelllistView1.SelectedFolder.PathName),
generic_read,0,@security,Open_existing,file_attribute_normal,0);
if (hfile=invalid_handle_value) then Label1.Caption:='Handle Invalido'
else Begin
getfileinformationbyhandle(hfile,fileinfo);
tamaño1:=fileinfo.nFileSizelow;
tamaño2:=fileinfo.nfilesizeHigh;
Label2.Caption:=inttostr(tamaño1);
Label3.Caption:=inttostr(tamaño2);
closehandle(hfile)
end;
tamaño1 siempre me da el valor 2.012.174.878
y tamaño2: 2.010.279.026
mientras que con el código de
http://www.delphi3000.com/articles/article_2686.asp
obtengo siempre el tamaño correcto.
¿Que es lo que está mal en el código anterior?
Los tipos están declarados como DWORD, igual que en el registro, las variables inicializadas, el Handle no me da error, etc, etc.
Gracias por vuestro valioso tiempo.
Saludos.