Compile a local service program and stop it after it is started.

Source: Internet
Author: User

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 );

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.