lhl60
asked on
useing readfileEx in Delphi 5
Hi there
I want to use simple overlapped I/O in Delphi 5
I've done it numerous times in Vs C++ so I know what to do,
I'm relatively in Delphi
And I have a syntax problem
compiler complains about "not enough actual parameters"
See code below
I can't see the problem, can you ?
Regards Lars
I want to use simple overlapped I/O in Delphi 5
I've done it numerous times in Vs C++ so I know what to do,
I'm relatively in Delphi
And I have a syntax problem
compiler complains about "not enough actual parameters"
See code below
I can't see the problem, can you ?
Regards Lars
type
Tbuffer = packed array[0..1024] of byte;
type
TMyoverlapped = class(Tobject)
Data:tbuffer;
overlapped:TOverlapped;
end;
// when posting a read
// the Buffer will be deleted on completion
Buffer:= TMyoverlapped.create;
ReadFileEx(handle,@Buffer.data,1024,@buffer.overlapped,_onSerialData);
//completion routine
procedure Tmainwindow._onSerialdata(Errorcode:integer; NumberOfbytesReceived:integer; overlapped:TOverlapped);
is _onSerialdata a method of Tmainwindow? If so, it can't be, it has to be a 'normal' function.
ASKER
Thanks,
Now I moved the onSerialdata to "global" scope, but I still get the "not enough parameters error" on the ReadfileEx call
I count and I count but I see enough parameter of correct types
Now I moved the onSerialdata to "global" scope, but I still get the "not enough parameters error" on the ReadfileEx call
I count and I count but I see enough parameter of correct types
did you add stdcall ?
procedure _onSerialdata(Errorcode:in teger; NumberOfbytesReceived:inte ger; overlapped:TOverlapped); stdcall;
procedure _onSerialdata(Errorcode:in
does it work without the completion routine ?
like this:
https://www.experts-exchange.com/questions/20053566/ReadFile-ReadFileEx-API-calls.html?qid=20053566
and what line does the compiler give an error on ...
it may the error is in the line above sometimes
like this:
https://www.experts-exchange.com/questions/20053566/ReadFile-ReadFileEx-API-calls.html?qid=20053566
and what line does the compiler give an error on ...
it may the error is in the line above sometimes
may this declaration will help in this reference:
http://ftp.escom.bg/Windows/winsite/JCL/jvcl/source/JvHidControllerClass.pas
look for ReadFileEx, you should find:
http://ftp.escom.bg/Windows/winsite/JCL/jvcl/source/JvHidControllerClass.pas
look for ReadFileEx, you should find:
var
// counter to prevent a second TJvHidDeviceController instance
GlobalInstanceCount: Integer = 0;
//== these are declared inconsistent in Windows.pas ============================
function ReadFileEx(hFile: THandle; var Buffer; nNumberOfBytesToRead: DWORD;
var Overlapped: TOverlapped; lpCompletionRoutine: TPROverlappedCompletionRoutine): BOOL; stdcall;
external 'kernel32.dll' name 'ReadFileEx';
function WriteFileEx(hFile: THandle; var Buffer; nNumberOfBytesToWrite: DWORD;
var Overlapped: TOverlapped; lpCompletionRoutine: TPROverlappedCompletionRoutine): BOOL; stdcall;
external 'kernel32.dll' name 'WriteFileEx';
ASKER
Stdcall now added ( what was i thinking ?)
but still no change
And the error seems to be here
ReadFileEx(handle,@Buffer. data,1024, @buffer.ov erlapped,o nSerialDat a)
error:
"not enough actual parameters"
and without completion:
ReadFile(handle,@Buffer.da ta,1024,@b uffer.over lapped)
error:
"types of actual and formal parameters must be identical"
I suspect it has to do with the @'s, My Delphi skills aren't that good
but still no change
And the error seems to be here
ReadFileEx(handle,@Buffer.
error:
"not enough actual parameters"
and without completion:
ReadFile(handle,@Buffer.da
error:
"types of actual and formal parameters must be identical"
I suspect it has to do with the @'s, My Delphi skills aren't that good
If you change the 'layout' of your code to like below, you might get more details on where in the arguments the compiler gives the error:
ReadFileEx(handle,
@Buffer.data,
1024,
@buffer.overlapped,
_onSerialData);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Changing the line to :
ReadFileEx(ComHandle,@Buff er.data,10 24,@buffer .overlappe d,@onSeria lData);
fixed the compilations errors:
Now I just have to make it work
Closing the thread now
Thanks for you interest
rgds. Lars
ReadFileEx(ComHandle,@Buff
fixed the compilations errors:
Now I just have to make it work
Closing the thread now
Thanks for you interest
rgds. Lars
ASKER
yes thank you