H
hebiao
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代码在编译时就会出现奇怪的异常!
unit Heartbeat;
interface
uses Windows;
var
TheProc: procedure of object;
implementation
const
Frequency = 100
// 100 ms = 10 beats per second
var
TimerID: Integer;
InProc: Boolean;
procedure HeartBeatProc (Wnd: hWnd
Msg, Event, dwTime: Integer)
stdcall;
begin
if (Assigned (TheProc)) and (InProc = False) then begin
InProc := True;
try
TheProc;
finally
InProc := False;
end;
end;
end;
initialization
SetTimer (0, 0, Frequency, @HeartBeatProc);
finalization
KillTimer (0, TimerID);
end.
异常是:[Warning] Heartbeat.pas(32): Unsafe code '@ operator'
[Fatal Error] Heartbeat.pas(40): Could not create output file
'H:/Work/Articles/The Delphi Magazine/This Month/Heartbeat.dcu'
第一个警告我明白,但是第二个我就不明白了!总共代码就没有第40行!!!
unit Heartbeat;
interface
uses Windows;
var
TheProc: procedure of object;
implementation
const
Frequency = 100
// 100 ms = 10 beats per second
var
TimerID: Integer;
InProc: Boolean;
procedure HeartBeatProc (Wnd: hWnd
Msg, Event, dwTime: Integer)
stdcall;
begin
if (Assigned (TheProc)) and (InProc = False) then begin
InProc := True;
try
TheProc;
finally
InProc := False;
end;
end;
end;
initialization
SetTimer (0, 0, Frequency, @HeartBeatProc);
finalization
KillTimer (0, TimerID);
end.
异常是:[Warning] Heartbeat.pas(32): Unsafe code '@ operator'
[Fatal Error] Heartbeat.pas(40): Could not create output file
'H:/Work/Articles/The Delphi Magazine/This Month/Heartbeat.dcu'
第一个警告我明白,但是第二个我就不明白了!总共代码就没有第40行!!!