procedure TimeProc(uTimerID uMessage: UINT;
dwUser dw dw: DWORD) stdcall;
begin
FormEditText:=FloatToStr(smmCount);
smmCount:=smmCount;
end;
procedure TFormFormCreate(Sender: TObject);
begin
ButtonCaption :=´开始倒计时´;
ButtonCaption :=´结束倒计时´;
ButtonEnabled :=False;
ButtonEnabled :=True;
TimerEnabled :=False;
smmCount:=;
sTimerCount:=;
sPCount:=;
end;
procedure TFormButtonClick(Sender: TObject);
var
lgTicklgTicklgPer:TLargeInteger;
fTemp:Single;
begin
ButtonEnabled :=True;
ButtonEnabled :=False;
TimerEnabled :=True;
TimerInterval :=;
proTimeCallback:=TimeProc;
hTimeID:=timeSetEvent(proTimeCallback);
actTime:=GetTickCount;
//获得系统的高性能频率计数器在一毫秒内的震动次数
QueryPerformanceFrequency(lgPer);
fTemp:=lgPer/;
iTen:=Trunc(fTemp*);
QueryPerformanceCounter(lgTick);
lgTick:=lgTick;
sPCount:=;
while sPCount> do begin
QueryPerformanceCounter(lgTick);
//如果时钟震动次数超过毫秒的次数则刷新Edit的显示
If lgTick lgTick > iTen Then begin
lgTick := lgTick;
sPCount := sPCount ;
EditText := FloatToStr(sPCount);
ApplicationProcessMessages;
end;
end;
end;
[] [] [] []