Re: Delphi.NET



kennedyri@xxxxxxxxx wrote:
On Jun 27, 3:41 am, "Daniel Hobson" <djhob1...@xxxxxxxxxxxx> wrote:

The source buffer? Are you sure you had the parameters in the right
order? Show your code.

--
Rob


Hi Rob,

Here is the code that we tried.

{$UNSAFECODE ON}
procedure TMainForm.Button1Click(Sender: TObject); unsafe;
type
TTestRec = record
t1: array [1 .. 38] of char;
t2: array [1 .. 22] of char;
end;
var
inputMsg : TBytes;
MyTest : TTestRec;
MySrcPtr : IntPtr;
begin
try
try
{ hostclient is an TidTCPClient component }
hostclient.Connect;
MySrcPtr := IntPtr.Create(@MyTest);
SetLength (inputMsg, 60);
hostclient.IOHandler.ReadBytes (inputMsg, 60, false);
Marshal.Copy(inputMsg, 0, MySrcPtr, 60);
hostclient.IOHandler.Writeln ('Reply');
except

end;
finally
{
Cleanup before exiting.
}
SetLength (inputMsg, 0);
end;
end;

.


Quantcast