Service control handler should only, well, handle control messages that are sent to the service (the ones shown in the examples you linked are SERVICE_CONTROL_STOP
and SERVICE_CONTROL_INTERROGATE
). These control messages are sent to the service from the environment.
The logic of your service should be implemented in the ServiceMain
function, when all required initialization is done. In the example at the URL in your post, the service logic code is put into the SvcInit
function (which is probably not the most appropriate name for a function that implements logic of a service).