F
fossil
Unregistered / Unconfirmed
GUEST, unregistred user!
把文件中的数据读到 一个记录类型的变量中:
文件中的数据是在C++中的结构体,把结构体中的数据以*byte(NH_PORTSTRUCT),byte流的形式写到文件里
typedef struct {
BYTE DGHead;
int BufLength;
} NH_PORTSTRUCT;
我要读到跟 NH_PORTSTRUCT结构类型一样记录类型中
type
NH_PORTSTRUCT = record
DGHead: Byte;
BufLength: Integer;
end;
PNH_PORTSTRUCT = ^NH_PORTSTRUCT;
应该怎么做??
我做的:
New(temp);
f:= TMemoryStream.Create;
f.LoadFromFile ('D:/temp/写备份文件/PortConfig.dat');
f.Seek (0, soFromBeginning);
f.Write (temp,18);
a:= temp^.RPortNo;
D:= temp^.DGHead;
showmessage(inttostr(a));//数据不对!!!!!!!!!!!!!1
f.Free;
Dispose(temp);
文件中的数据是在C++中的结构体,把结构体中的数据以*byte(NH_PORTSTRUCT),byte流的形式写到文件里
typedef struct {
BYTE DGHead;
int BufLength;
} NH_PORTSTRUCT;
我要读到跟 NH_PORTSTRUCT结构类型一样记录类型中
type
NH_PORTSTRUCT = record
DGHead: Byte;
BufLength: Integer;
end;
PNH_PORTSTRUCT = ^NH_PORTSTRUCT;
应该怎么做??
我做的:
New(temp);
f:= TMemoryStream.Create;
f.LoadFromFile ('D:/temp/写备份文件/PortConfig.dat');
f.Seek (0, soFromBeginning);
f.Write (temp,18);
a:= temp^.RPortNo;
D:= temp^.DGHead;
showmessage(inttostr(a));//数据不对!!!!!!!!!!!!!1
f.Free;
Dispose(temp);