LPARAMETERS parm1, parm2 #define TIMERINT 5 && # of seconds for timer interval. &&Also syncs to TIMERINT seconds for time of day PUBLIC oService oService=NEWOBJECT("vfpsrv") oService.logstr("Starting Service: got some params: "+TRANSFORM(parm1)+" "+TRANSFORM(parm2)) IF _vfp.StartMode>0 && if we’re running as an EXE READ events && message loop ENDIF RETURN DEFINE CLASS vfpsrv AS form PROCEDURE Init this.logstr(FULLPATH("")) DECLARE integer MessageBeep IN WIN32API integer this.AddObject("mytimer","mytimer") WITH this.mytimer .enabled=.t. .interval=1000 && start it in a sec ENDWITH PROCEDURE Destroy ?PROGRAM() MessageBeep(32) PROCEDURE logstr(str as String) str=TRANSFORM(DATETIME())+" "+str+CHR(13)+CHR(10) ??str STRTOFILE(str, "h:\tmp\vfpsrv.log",.t.) ENDDEFINE DEFINE CLASS mytimer AS timer PROCEDURE timer DO ("vfpsrvrtn" ) with this, oService CLEAR PROGRAM dtNow=DATETIME() && read datetime() and seconds() close to the same instant nsec=SECONDS() nsec=CEILING((nsec+.5)/TIMERINT)*TIMERINT dtTarget=DTOT(DATE())+nsec this.interval=(dtTarget-dtNow) * 1000 ENDDEFINEAnd here is the code for vfpsrvrtn.prg
LPARAMETERS oTimer,oService oService.logstr(PROGRAM()) Messagebeep(0)>Anyway there is an obscure part (parameter passing) that was a bit hard to figure out when registering the service (registry and instsrv). We found elsewhere instsrvw.exe that found a lot less cumbersome.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VFPSrv\Parameters] "AppDirectory"="d:\\fox90\\test" "Application"="d:\\fox90\\test\\vfpsrv.exe" "AppParameters"="myparm1 myparm2"actually didn't work.