关于数据结构的收发,应该先在Delphi中定义一个与VC中的一模一样的结构,
这样,当收到VC发过来的信息后,用指针将其强行写入Delphi的结构变量中.
type
Socket_Bao=Record
DWord PType;
Byte recnum;
Byte totalrec;
Byte endflag;
DWord Request;
DWord Answer;
Byte Apu;
Byte Channel;
end;
...
var
xx:Socket_Bao;
P0,P1,i:Byte;
begin
P0:=@TempRecvBuf[0];
P1:=@xx;
for i:=1 to sizeof(Socket_Bao) do
begin
P1^:=P0^;
Inc(P0);
Inc(P1);
end;
//现在你就可以访问xx的属性了
...
end;
这样,当收到VC发过来的信息后,用指针将其强行写入Delphi的结构变量中.
type
Socket_Bao=Record
DWord PType;
Byte recnum;
Byte totalrec;
Byte endflag;
DWord Request;
DWord Answer;
Byte Apu;
Byte Channel;
end;
...
var
xx:Socket_Bao;
P0,P1,i:Byte;
begin
P0:=@TempRecvBuf[0];
P1:=@xx;
for i:=1 to sizeof(Socket_Bao) do
begin
P1^:=P0^;
Inc(P0);
Inc(P1);
end;
//现在你就可以访问xx的属性了
...
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货