The use of SetTimer function in Delphi

Source: Internet
Author: User

Delphi The settimer function is used to make timers that can run a program at intervals, requiring two functions, settimer functions, and KillTimer functions.
The following is a simple example:
Var
I:integer = 0;

Procedure Timerproc (Hwnd:hwnd;umsg,idevent:uint;dwtime:dword); stdcall;
Begin
Inc (I);
Form1.caption: = IntToStr (i);
End

Procedure Tform1.formcreate (Sender:tobject);
Begin
SetTimer (handle,10,500, @TimerProc);
End

Procedure Tform1.formdestroy (Sender:tobject);
Begin
KillTimer (handle,10);
End

Sensitive 360 will see this program as a Trojan horse, it may be a lot of Trojans will use a similar timer function bar, SetTimer function almost become a feature of the Trojan Horse

Parameter explanation:

SetTimer altogether four parameters:

1. The handle,windows of the calling function will periodically send WM_TIMER messages to this handle

2.timer identification, can be set to 0

3. The value of the timer, in milliseconds

4. Callback function

1th, 2 parameters can be arbitrarily set, note that the second parameter must be a number, the corresponding killtimer of the first two parameters must be the same as the SetTimer parameter.

The use of SetTimer function in Delphi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.