Eu estava usando a função que peguei do link que vc passou, que estava compilando e até executando normalmente (abria o serviço, mas não executava a minha função), como te escrevi antes.
Entretanto, ao tentar substituir pela função que vc postou aqui, ela não compila. Dá os seguintes erros:
Error E2206 tar2p.prg 125: Illegal character '#' (0x23)
Error E2141 tar2p.prg 125: Declaration syntax error
Error E2451 tar2p.prg 159: Undefined symbol 'ssStatus' in function HB_FUN_ISSERVICERUNNING
Error E2451 tar2p.prg 179: Undefined symbol 'SZSERVICENAME' in function HB_FUN_SERVICEDISPATCH
Error E2141 tar2p.prg 179: Declaration syntax error in function HB_FUN_SERVICEDISPATCH
Error E2139 tar2p.prg 179: Declaration missing ; in function HB_FUN_SERVICEDISPATCH
Warning W8004 tar2p.prg 179: 'dispatchTable' is assigned a value that is never used in function HB_FUN_SERVICEDISPATCH
Error E2190 tar2p.prg 179: Unexpected }
Error E2040 tar2p.prg 179: Declaration terminated incorrectly
Error E2190 tar2p.prg 181: Unexpected }
Error E2190 tar2p.prg 181: Unexpected }
Error E2040 tar2p.prg 182: Declaration terminated incorrectly
Error E2190 tar2p.prg 185: Unexpected }
Error E2451 tar2p.prg 206: Undefined symbol 'SZSERVICENAME' in function service_main
Error E2451 tar2p.prg 213: Undefined symbol 'ssStatus' in function service_main
Error E2451 tar2p.prg 253: Undefined symbol 'ssStatus' in function service_ctrl
Error E2451 tar2p.prg 315: Undefined symbol 'SZSERVICEDISPLAYNAME' in function ServiceStart
Error E2451 tar2p.prg 404: Undefined symbol 'ssStatus' in function ReportStatusToSCMgr
Warning W8004 tar2p.prg 426: 'dwCheckPoint' is assigned a value that is never used in function ReportStatusToSCMgr
Warning W8057 tar2p.prg 426: Parameter 'dwWin32ExitCode' is never used in function ReportStatusToSCMgr
Warning W8057 tar2p.prg 426: Parameter 'dwWaitHint' is never used in function ReportStatusToSCMgr
Error E2451 tar2p.prg 453: Undefined symbol 'function' in function AddToMessageLog
Error E2379 tar2p.prg 453: Statement missing ; in function AddToMessageLog
Error E2206 tar2p.prg 478: Illegal character '@' (0x40) in function AddToMessageLog
Error E2206 tar2p.prg 505: Illegal character '@' (0x40) in function AddToMessageLog
Error E2206 tar2p.prg 506: Illegal character '@' (0x40) in function AddToMessageLog
Error E2206 tar2p.prg 507: Illegal character '@' (0x40) in function AddToMessageLog
Error E2206 tar2p.prg 508: Illegal character '@' (0x40) in function AddToMessageLog
Error E2206 tar2p.prg 509: Illegal character '@' (0x40) in function AddToMessageLog
Error E2228 tar2p.prg 509: Too many error or warning messages in function AddToMessageLog
*** 26 errors in Compile ***
Type: C >>>Couldn't build: tar2p.obj<<<
Quando combino apenas a última parte que vc mandou com a função que baixei do link que vc tinha postado, ela compila normalmente, mas continua não executando as minhas funções.
Minha função está assim:
**********************service.ch**********************
#define SZSERVICENAME "FirstxHarbourService"
#define SZVERSION "1.0"
#define SZSERVICEDISPLAYNAME "My first xHarbour Service"
#define SZAPPNAME "service"
#define SZDEPENDENCIES ""
*******Service.prg**************
Function Main(cParameter)
if cParameter == NIL
cParameter:=""
end
if left(cParameter,1) != "-"
cParameter:=""
else
cParameter:=Upper(Substr(cParameter,2))
endif
Do Case
Case cParameter == "INSTALL"
CmdInstallService()
Case cParameter== "REMOVE"
CmdRemoveService()
Case cParameter == "HELP"
CmdHelp()
Case cParameter == "VERSION"
CmdVersion()
OtherWise
ServiceDispatch()
End Case
ExecuteService()
// parar o serviço em algum ponto
Return NIL
#include "fileio.ch"
Function ExecuteService()
LOCAL nHandle, cString, nTimes := 0
do while IsServiceRunning() .And. nTimes <= 5
cString := Dtos(Date()) + '-' + Time()
//
nHandle := FOPEN( StrTran( cString, ":","" ) + ".Txt", FO_READWRITE + FO_SHARED )
tar2p() //Esta é a minha função
IF FERROR() == 0
FWrite( nHandle, "Data e hora atual do sistema: " + cString )
FClose( nHandle )
nTimes++
ENDIF
SecondsSleep( 60 ) // Aguarda um minuto e volta
enddo
Return NIL
//--------------------------------------------------------------------------------------------------
#pragma BEGINDUMP
...
function tar2p
...
//Aqui eu fiz vários testes, criando arquivos, testando com o tone, mandando e-mails etc; nada roda