Mayco
Member
I have a problem: when I use the readfile api function in delphi it returns everything what i need except the first byte (when the file begins with "123..." it just returns "23...").
This is the piece of code I use:
procedure openfile();
var
dwread:LongWord;
hFile: THandle;
data: Shortstring;
begin
hFile := createfile(PChar('c:\file.bin'), GENERIC_READ, FILE_SHARE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL + FILE_FLAG_RANDOM_ACCES, 0);
SetFilePointer(hFile, 0, nil, FILE_BEGIN);
Readfile(hFile, data, 64, dwread, nil);
Closehandle(hFile);
end;
c:\file.bin is the file I want to read of course.
data must contain the first 64 bytes of a binary file but it doesn't add the first byte.
This is the piece of code I use:
procedure openfile();
var
dwread:LongWord;
hFile: THandle;
data: Shortstring;
begin
hFile := createfile(PChar('c:\file.bin'), GENERIC_READ, FILE_SHARE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL + FILE_FLAG_RANDOM_ACCES, 0);
SetFilePointer(hFile, 0, nil, FILE_BEGIN);
Readfile(hFile, data, 64, dwread, nil);
Closehandle(hFile);
end;
c:\file.bin is the file I want to read of course.
data must contain the first 64 bytes of a binary file but it doesn't add the first byte.