Page 1 of 1

Compile error calling ReadFile from Delphi 2007

Posted: Thu 13 Oct 2016 20:56
by keithmur
We have a Delphi 2007 program that used SecureBridge 2.6.

When we install SecureBridge 7.0.1 or 7.1.2, and try to compile our program, we get the error:

'There is no overloaded version of 'ReadFile' that can be called with these arguments.'

The offending code looks like this:

h: TScSFTPFileHandle;
buf: array [0..32767] of byte;
count: integer;
pos: int64;
begin
fs := TFileStream.Create(LocalFilename, fmCreate);
try
h := FFTPCli.OpenFile(RemoteFilename, fmOpenExisting);

pos := 0;
count := FFTPCli.ReadFile(h, pos, buf, SizeOf(buf));

It looks like an overload of ReadFile may have been removed in these versions.

I tried changing the call to use the other overload, the one that requires the offset, like this:

count := FFTPCli.ReadFile(h, pos, buf, 0, SizeOf(buf));

But that gets the same error.

Do you have an example of Delphi code that would work with this function now? Or know what I can do to fix the original issue?

Thanks.

Re: Compile error calling ReadFile from Delphi 2007

Posted: Mon 17 Oct 2016 10:11
by ViktorV
The latest versions of SecureBridge uses the TScSFTPClient.ReadFile method of the following signature:

Code: Select all

function ReadFile(const Handle: TScSFTPFileHandle; FileOffset: Int64; var Buffer: TBytes; Offset, Count: integer): integer; {$ IFNDEF CLR}overload;{$ ENDIF}
To obtain the necessary information about using this method, you can use our SFTPClient demo project that can be found in the 'Demos\SFTPClient' folder relatively to the SecureBridge demos installation path.

Re: Compile error calling ReadFile from Delphi 2007

Posted: Tue 18 Oct 2016 15:30
by keithmur
Thanks - that should help.

I am running into an issue compiling the demo project:

Code: Select all

Unit ScAlgorithmSupport was compiled with a different version of Zlib.TZStreamRec
But I am guessing this is an issue in our environment that you cannot address, not sure.

Re: Compile error calling ReadFile from Delphi 2007

Posted: Tue 18 Oct 2016 18:12
by keithmur
The latter *was* an issue in our environment.

I was able to figure out what how to get around the original compiler error: our variable 'buf' *must* be declared as a TBytes. Even though TBytes is declared as array of byte, if we declare buf as an array of byte, rather than TBytes, we get the error.

The thing that was really getting me though, is it turned out we had another definition of TByte in a module other than SysUtils. But it was the same, 'array of byte'!

The answer for us is to declare buf as Sysutils.TBytes.

Thanks for your help.

Re: Compile error calling ReadFile from Delphi 2007

Posted: Wed 19 Oct 2016 08:51
by ViktorV
We are glad to know you have found a solution for the issue.
Feel free to contact us if you have any further questions about our products.