我用delphi中的纪录模拟c++中的远程结构体指针接收传回来的数据有错误!程序清单:(省略部分代码,这是关键部分,不知道为什么收到的数据总是乱码)//纪录定义:
tagRCV_REPORT_STRUCTE=RECORD
// 2001.11.7 添加 m_cbSize
m_cbSize: WORD; // 数据结构大小
m_time: TDateTime; // 交易时间 m_wMarket: WORD; // 股票市场类型
m_szLabel: array[0..STKLABEL_LEN] of char; // 股票代码,以'\0'结尾
m_szName: array[0..STKNAME_LEN] of char; // 股票名称,以'\0'结尾 m_fLastClose: single; // 昨收
m_fOpen: single; // 今开
m_fHigh: single; // 最高
m_fLow: single; // 最低
m_fNewPrice: single; // 最新
m_fVolume: single; // 成交量
m_fAmount: single; // 成交额 m_fBuyPrice:array[0..3] of single; // 申买价1,2,3
m_fBuyVolume:array[0..3] of single; // 申买量1,2,3
m_fSellPrice:array[0..3] of single; // 申卖价1,2,3
m_fSellVolume:array[0..3] of single; // 申卖量1,2,3
// 2001.11.7 添加,支持深圳6位代码
m_fBuyPrice4:single; // 新添加的买卖4
m_fBuyVolume4:single;
m_fSellPrice4:single;
m_fSellVolume4:single;
end;
RCV_REPORT_STRUCTE=^tagRCV_REPORT_STRUCTE;
//函数定义:
GetNo = function(nNo:Longint;PRCV_REPORT_STRUCTE:RCV_REPORT_STRUCTE):integer;stdcall;
//调用过程
procedure TActionM_Form.GetFormNO; //条件查询
var
GetNoP:TFarProc;
re:dword;
PRCV_REPORT_STRUCTE:RCV_REPORT_STRUCTE;
s:string;
begin
GetNoP:=GetProcAddress(StockMoudle,'GetStockByNo');
if GetNoP=nil then
messagedlg('没有加载DLL',mtConfirmation, [mbYes], 0);
if GetNoP<>nil then
begin
//EnableNewFormat;
New(PRCV_REPORT_STRUCTE);
PRCV_REPORT_STRUCTE.m_cbSize:=sizeof(tagRCV_REPORT_STRUCTE);
PRCV_REPORT_STRUCTE.m_szLabel:='600001\0';
re:=GetNo(GetNoP)(10,PRCV_REPORT_STRUCTE);
s:=floattostr(PRCV_REPORT_STRUCTE.m_fOpen);
ActionL_ListView.Items.Add.SubItems.Add(s);
if re=0 then Messagedlg('失败',mtInformation,[MBOK],0);
dispose(PRCV_REPORT_STRUCTE);
end;
end;
tagRCV_REPORT_STRUCTE=RECORD
// 2001.11.7 添加 m_cbSize
m_cbSize: WORD; // 数据结构大小
m_time: TDateTime; // 交易时间 m_wMarket: WORD; // 股票市场类型
m_szLabel: array[0..STKLABEL_LEN] of char; // 股票代码,以'\0'结尾
m_szName: array[0..STKNAME_LEN] of char; // 股票名称,以'\0'结尾 m_fLastClose: single; // 昨收
m_fOpen: single; // 今开
m_fHigh: single; // 最高
m_fLow: single; // 最低
m_fNewPrice: single; // 最新
m_fVolume: single; // 成交量
m_fAmount: single; // 成交额 m_fBuyPrice:array[0..3] of single; // 申买价1,2,3
m_fBuyVolume:array[0..3] of single; // 申买量1,2,3
m_fSellPrice:array[0..3] of single; // 申卖价1,2,3
m_fSellVolume:array[0..3] of single; // 申卖量1,2,3
// 2001.11.7 添加,支持深圳6位代码
m_fBuyPrice4:single; // 新添加的买卖4
m_fBuyVolume4:single;
m_fSellPrice4:single;
m_fSellVolume4:single;
end;
RCV_REPORT_STRUCTE=^tagRCV_REPORT_STRUCTE;
//函数定义:
GetNo = function(nNo:Longint;PRCV_REPORT_STRUCTE:RCV_REPORT_STRUCTE):integer;stdcall;
//调用过程
procedure TActionM_Form.GetFormNO; //条件查询
var
GetNoP:TFarProc;
re:dword;
PRCV_REPORT_STRUCTE:RCV_REPORT_STRUCTE;
s:string;
begin
GetNoP:=GetProcAddress(StockMoudle,'GetStockByNo');
if GetNoP=nil then
messagedlg('没有加载DLL',mtConfirmation, [mbYes], 0);
if GetNoP<>nil then
begin
//EnableNewFormat;
New(PRCV_REPORT_STRUCTE);
PRCV_REPORT_STRUCTE.m_cbSize:=sizeof(tagRCV_REPORT_STRUCTE);
PRCV_REPORT_STRUCTE.m_szLabel:='600001\0';
re:=GetNo(GetNoP)(10,PRCV_REPORT_STRUCTE);
s:=floattostr(PRCV_REPORT_STRUCTE.m_fOpen);
ActionL_ListView.Items.Add.SubItems.Add(s);
if re=0 then Messagedlg('失败',mtInformation,[MBOK],0);
dispose(PRCV_REPORT_STRUCTE);
end;
end;
//纪录定义:
tagRCV_REPORT_STRUCTE = packed RECORD
// 2001.11.7 添加 m_cbSize
m_cbSize: WORD; // 数据结构大小
m_time: TDateTime; // 交易时间