It's pretty much exactly the same as the example code above, just call StartServiceCtrlDispatcher in the case when the command line argument isn't "install" "remove" or anything else used to control installation status. For a concrete example/code, see here.