Please refer to the topic "Using Services" in MSDN, it show you all steps to implement a service program under Windows NT/2000Writing a service program's main function 
Writing a ServiceMain function 
Writing a control handler function 
Opening an SCManager database 
Installing a service 
Deleting a service 
Changing a service configuration 
Querying a service's configuration 
Starting a service 
Sending control requests to a service