通达信dll插件Delphi

更新时间:2024-07-01 18:23:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

library tdxdlltest;

{通达信dll公式函数规范 delphi版 2016.03.05 } uses

SysUtils,Windows;

{$R *.res} type

ArraySingle=array of single; type

pPluginFUNC = procedure(p1: Integer; var p2, p3, p4, p5: ArraySingle); cdecl;//不要修改

tagPluginTCalcFuncInfo = packed record nFuncMark: Word; pCallFunc: pPluginFUNC; end;

PluginTCalcFuncInfo = tagPluginTCalcFuncInfo; PPluginTCalcFuncInfo = ^PluginTCalcFuncInfo; PPPluginTCalcFuncInfo = ^PPluginTCalcFuncInfo;

pRegisterPluginFUNC = function(pFun: PPPluginTCalcFuncInfo):LongBool;cdecl;

var

g_CalcFuncSets: array[0..2] of PluginTCalcFuncInfo;

procedure

TestPlugin1(DataLen:integer;pfOUT:ArraySingle;pfINa:ArraySingle;pfINb:ArraySingle;pfINc:ArraySingle);cdecl;

var // F8F8F8F8 表示无效数据,通达信公式中将不会显示 i:integer; pc1:PCardinal; begin

for i:=0 to datalen-1 do begin

pfOUT[i]:=pfina[i]; if i>=datalen-10 then begin

pc1:=@pfout[i]; pc1^:=$F8F8F8F8; end; end; end;

{通达信dll公式函数规范 delphi版 悟多qq911322 2016.03.05 ,像悟多先生致谢~ } procedure

TestPlugin2(DataLen:integer;pfOUT:ArraySingle;pfINa:ArraySingle;pfINb:ArraySingle;pfINc:ArraySingle);cdecl; var i:integer; begin

for i:=0 to datalen-1 do begin

pfOUT[i]:=pfina[i]+1;//返回值是输入值+1

end; end;

procedure

TestPlugin3(DataLen:integer;pfOUT:ArraySingle;pfINa:ArraySingle;pfINb:ArraySingle;pfINc:ArraySingle);cdecl; var i:integer; begin

for i:=0 to datalen-1 do begin

pfOUT[i]:=pfinc[i]; end; end;

procedure InitStruct; begin

g_CalcFuncSets[0].nFuncMark := 1;

g_CalcFuncSets[0].pCallFunc := @TestPlugin1; g_CalcFuncSets[1].nFuncMark := 2;

g_CalcFuncSets[1].pCallFunc := @TestPlugin2; g_CalcFuncSets[2].nFuncMark := 3;

g_CalcFuncSets[2].pCallFunc := @TestPlugin3; //有更多的函数的话,可以增加到这里 end;

function RegisterTdxFunc(pFun: PPPluginTCalcFuncInfo): LongBool; cdecl; begin

Result := False; if pFun^ = nil then begin

pFun^ := @g_CalcFuncSets; //绑定dll函数起始地址 Result := True;

end; end; exports

RegisterTdxFunc; begin InitStruct; end.

本文来源:https://www.bwwdw.com/article/199.html

Top