How to compile local servicesProgramHere we will not introduce it much. We can use the built-in "service application" of Delphi to create a service. The operation is similar to creating a VCL from.
This article mainly introduces a problem: a service is compiled. The main operation is to regularly append the log to a file, which is processed in timer. However, after the service is registered, by starting the service in the Service Manager, the system always reports a message similar to "the service is stopped when the service is not started, and no other programs are called". It is not clear at first that one person is related to the previous permissions, I changed the log field to create a file (in fact, the permissions are similar), but I found that the log is not available. I asked other people, some people give an opinion that "some files are called in the service, but the reason is not found", such as the Compilation instruction of "using fulldebugmoude, however, the released program cannot be started if "fastmm4_debug.dll" is not added, but it cannot be started after the program is streamlined again and again. Finally, the onexcute event is removed and the result can be used, then the problem should occur in the event, through the attach method of Delphi, start to debug the program, and find that there is no error in the execution process, but it stops after execution.
I learned about it online: The reason is that in onexcuteServicethreadIt is a thread. After the thread is executed, it will kill itself, and the end of the service is the completion of the content in onexcute, so the program will stop after the execution, this leads to the problem.
The solution to this problem is to increase the numberCodeIn the onexcute event
While not terminated do
Servicethread. processrequests (false );