J
javesun
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
PTxPacketHead=^TxPacketHead;
TxPacketHead = packed record
dwSignature: longword
//
iLength: integer
//
dwOrdinal: longword
//
dwChecksum: longword
//
END;
PTest = ^TTest;
TTest = Record
test1: SmallInt;
test2: SmallInt;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
PTxPacketHead1: PTxPacketHead;
PTest1: PTest;
sStr: String;
begin
sStr:= 'abcdefghaaadfdfa';
PTest1:= PTest(Copy(sStr, 1, 4))
// .....???
PTxPacketHead1:= PTxPacketHead(Copy(sStr, 1, 16))
//......???
ShowMessage(inttostr(PTest1.test1)+' : '+inttostr(PTxPacketHead1.dwSignature));
end;
end.
哪位大虾来告诉俺一声,这个转换是怎么转换的?
另外,ShowMessage显示的是些什么东东?
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
PTxPacketHead=^TxPacketHead;
TxPacketHead = packed record
dwSignature: longword
//
iLength: integer
//
dwOrdinal: longword
//
dwChecksum: longword
//
END;
PTest = ^TTest;
TTest = Record
test1: SmallInt;
test2: SmallInt;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
PTxPacketHead1: PTxPacketHead;
PTest1: PTest;
sStr: String;
begin
sStr:= 'abcdefghaaadfdfa';
PTest1:= PTest(Copy(sStr, 1, 4))
// .....???
PTxPacketHead1:= PTxPacketHead(Copy(sStr, 1, 16))
//......???
ShowMessage(inttostr(PTest1.test1)+' : '+inttostr(PTxPacketHead1.dwSignature));
end;
end.
哪位大虾来告诉俺一声,这个转换是怎么转换的?
另外,ShowMessage显示的是些什么东东?