DLL问题
看了一个用线程和消息循环的方法让DLL代码自动运行的例子,可编译不能通过。能否帮我查一下怎回事,好希望调用dll不用传指针参数。
谢谢
library Project1;
uses
SysUtils,
windows,
Classes;
type
TMyThread = class(TThread)
private
FTimer:TTimer;
procedure TimerProc(Sender: TObject);
protected
procedure Execute;override;
public
constructor Create;override;
procedure KillIt;//结束
end;
var
x,y,z:integer ;
{$R *.res}
function Add():integer;stdcall;
begin
x:=random(100);
y:=random(300);
z:=x+y;
result:= z;
end;
procedure TMyThread.TimerProc(Sender: TObject);
begin
Add();
end;
procedure TMyThread.KillIt;
begin
PostMessage(Handle,WM_QUIT,0,0);
end;
procedure TMyThread.Execute;
begin
FTimer:=TTimer.Create(nil);
try
try
FTimer.Enabled:=true;//false
FTimer.OnTimer:=TimerProc;
while GetMessage(MsgRec, 0, 0, 0) do begin
TranslateMessage(MsgRec);
DispatchMessage(MsgRec)
end;
Terminate;
finally
FSocket.Free;
end;
finally
FTimer.Free;
end;
end;
exports
Add;
begin
end.