3
32881
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
hTimer: LongWord=0;
// 删除定时器
procedure DownTimerOff;
begin
if (hTimer <> 0) then
begin
KillTimer(0, hTimer);
hTimer := 0;
end;
end;
procedure TimerProc();
begin
DownTimerOff;
MessageBox(0, '定时器执行成功!!', '提示', mb_iconinformation);
end;
// 安装定时器
procedure DownTimerOn;
begin
if (hTimer <> 0) then DownTimerOff;
hTimer := SetTimer(0, 0,5000, @TimerProc);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DownTimerOn;
end;
end.
在有窗体的程序中定时器运行正常...
在无窗体的控制台程序下..
program Project2;
uses
windows;
var
hTimer: LongWord=0;
// 删除定时器
procedure DownTimerOff;
begin
if (hTimer <> 0) then
begin
KillTimer(0, hTimer);
hTimer := 0;
end;
end;
procedure TimerProc();
begin
DownTimerOff;
MessageBox(0, '定时器执行成功!!', '提示', mb_iconinformation);
end;
// 安装定时器
procedure DownTimerOn;
begin
if (hTimer <> 0) then DownTimerOff;
hTimer := SetTimer(0, 0,5000, @TimerProc);
end;
begin
DownTimerOn;
end.
为什么程序不安装定时器?如何解决这个问题?请各位前辈指教..
请说明完整,谢谢...
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
hTimer: LongWord=0;
// 删除定时器
procedure DownTimerOff;
begin
if (hTimer <> 0) then
begin
KillTimer(0, hTimer);
hTimer := 0;
end;
end;
procedure TimerProc();
begin
DownTimerOff;
MessageBox(0, '定时器执行成功!!', '提示', mb_iconinformation);
end;
// 安装定时器
procedure DownTimerOn;
begin
if (hTimer <> 0) then DownTimerOff;
hTimer := SetTimer(0, 0,5000, @TimerProc);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DownTimerOn;
end;
end.
在有窗体的程序中定时器运行正常...
在无窗体的控制台程序下..
program Project2;
uses
windows;
var
hTimer: LongWord=0;
// 删除定时器
procedure DownTimerOff;
begin
if (hTimer <> 0) then
begin
KillTimer(0, hTimer);
hTimer := 0;
end;
end;
procedure TimerProc();
begin
DownTimerOff;
MessageBox(0, '定时器执行成功!!', '提示', mb_iconinformation);
end;
// 安装定时器
procedure DownTimerOn;
begin
if (hTimer <> 0) then DownTimerOff;
hTimer := SetTimer(0, 0,5000, @TimerProc);
end;
begin
DownTimerOn;
end.
为什么程序不安装定时器?如何解决这个问题?请各位前辈指教..
请说明完整,谢谢...