how to make a timer in dll use delphi ?

 

i want to make a dll,it works independently from its caller .

it is triggered by a Timer,there should be a procedure that do something and get an initial data.

there should be a function and calculate the data and export the result .

my thoughts as follow, but the code does not work,will someone like to help me to modify it ? thanks

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

library dlltest;

uses
SysUtils, windows, Classes;
var
x,y,z,TimeID:integer;
{$R *.res}

procedure aaaa();//////////////////////////////get inial data
begin
x:=random(100);
y:=random(30);
end;


procedure TimerProc(hWn:HWND;nMsg:integer;nTimerid:DWORD;dwTime:DWORD);stdcall;

begin
aaaa();

function add():integer;stdcall;
begin
z:=x+y;
result:= z;
end;

end;
exports
add();

begin

TimeID:=settimer(0,1,2000,@TimerProc);
KillTimer(0, TimeID);
end.

 

Hi YW

I don't fully understand what you are after but I would suggest using Lazarus with free Pascal because more people will be able to help you. The guy 7Bit on this site has written a post on another site about how to use Lazarus with MT4 to create DLLs (search here for Lazarus) and in FPC under sysutils there are time functions to do what you require.

 

hi, i do not hear you for more then half a year .

i

 
Ruptor:

Hi YW

I don't fully understand what you are after but I would suggest using Lazarus with free Pascal because more people will be able to help you. The guy 7Bit on this site has written a post on another site about how to use Lazarus with MT4 to create DLLs (search here for Lazarus) and in FPC under sysutils there are time functions to do what you require.


hi ruptor

i have downloaded FPC lazarus,but i can not add timer or Idletimer to dll codes,though there are in system panel .

can you help me and give an exmple ?

 

Hi YW

I am new to Lazarus and have not used timers yet. I think the icons are for use in programs that use forms but DLLs don't have forms. You could start a prog with a form and pinch the bit of code for your DLL that sets the timer. Also look at the RTLs & FCLs in the on line help there is timer stuff under FCL, fptimers with examples. For DLLs in MT4 see 7Bit post of examples here

http://www.forexfactory.com/showthread.php?t=219576
Reason: