Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I alwasy use something like this in a Service:</p> <pre><code>unit uCopy; interface uses Windows, Messages,.......; procedure MyTimerProc(hWindow : HWND; uMsg : cardinal; idEvent : cardinal; dwTime : DWORD); stdcall; type TFileCopy= class(TService) procedure ServiceStart(Sender: TService; var Started: Boolean); procedure ServiceStop(Sender: TService; var Stopped: Boolean); private { Private declarations } public { Public declarations } end; VAR timerID : UINT; const SECONDS = 900000; procedure TFileCopy.ServiceStart(Sender: TService; var Started: Boolean); Begin timerID := 0; //Probably not needed. timerID := SetTimer(0, 1, SECONDS, @MyTimerProc); End; procedure MyTimerProc(hWindow : HWND; uMsg : cardinal; idEvent : cardinal;dwTime : DWORD); stdcall; Begin //Kill timer while trying.. If this function takes longer than the interval to run, I didn't want a build up. If that was possible. KillTimer(0, timerID); timerID := 0; //Is it needed? //DO WORK. { //I was Connecting to a Network Drive, Minutes, seconds..... //I only wanted to run this Every day at 2 AM. //So I had my timer set to 15 minutes, once it got between 30 and 10 minutes of my 2 AM deadline, //i killed the existing timer and started a new one at 60000. //If it was within 10 minutes of my 2 AM, my interval changed to 500. //This seems to work for me, my files get copied everyday at 2 AM. } //Work Complete. Start timer back up. timerID := SetTimer(0, 1, SECONDS, @MyTimerProc); End; procedure TFileCopy.ServiceStop(Sender: TService; var Stopped: Boolean); Begin if timerID &gt; 0 then KillTimer(0, timerID); End; </code></pre> <p>Of course, I had some Try..Catch in most places along with writing to logs and emailing.... I've got a service running using these techniques for over a year now. By no means is it the rule. Please tell me if there is a better way. I'm always looking for ways to improve my Delphi knowledge. Also, sorry if I missed the deadline for posting to a question.</p> <p>-Trey Aughenbaugh</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload