-
-
[求助]DLL中使用SetTimer Delphi
-
发表于:
2008-6-25 18:34
9072
-
[求助]DLL中使用SetTimer Delphi
library Project2;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
begin
xzcx;
end.
unit Unit1;
interface
uses Windows,SysUtils;
var
t1: LongWord=0; // 定时器句柄
procedure xzcx();
procedure TimerOn; // 安装定时器
procedure TimerOff; // 删除定时器
implementation
Procedure WriteTxt(sFileName,sText:String); //写txt文件
Var
F:TextFile;
Begin
AssignFile(F,sFileName);
IF FileExists(sFileName) Then
Append(F)
Else
ReWrite(F);
WriteLn(F,sText);
CloseFile(F);
End;
procedure TimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; dwTime: DWORD); stdcall;
begin
WriteTxt('0.txt','正在执行定时器'+ inttostr(t1));
end;
procedure xzcx();
begin
TimerOn;
WriteTxt('0.txt','启动定时器'+ inttostr(t1));
end;
procedure TimerOn;
begin
if (t1 <> 0) then TimerOff;
t1:= SetTimer(0, 0, 100, @TimerProc);
end;
procedure TimerOff;
begin
if (t1 <> 0) then
begin
KillTimer(0, t1);
t1 := 0;
end;
end;
end.
结果
启动定时器28535
启动定时器32759
没有执行,为什么会这样呢?
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)