Some times we will get linker errors like below when creating winservice.
To solve this add following code.
#pragma comment (lib, "advapi32.lib")
#pragma comment (lib, "user32.lib")
Or
include user32.lib and advapi32.lib in linker input of project settings
error LNK2019: unresolved external symbol __imp__CloseServiceHandle@4 referenced in function
error LNK2019: unresolved external symbol __imp__CreateServiceA@52 referenced in function
error LNK2019: unresolved external symbol __imp__OpenSCManagerA@12 referenced in function
error LNK2019: unresolved external symbol __imp__DeleteService@4 referenced in function
error LNK2019: unresolved external symbol __imp__OpenServiceA@12 referenced in function
error LNK2019: unresolved external symbol __imp__ControlService@12 referenced in function
error LNK2019: unresolved external symbol __imp__StartServiceA@12 referenced in function
error LNK2019: unresolved external symbol __imp__StartServiceCtrlDispatcherA@4 referenced in function
error LNK2019: unresolved external symbol __imp__SetServiceStatus@8 referenced in function
error LNK2019: unresolved external symbol __imp__RegisterServiceCtrlHandlerA@8 referenced in function
error LNK2019: unresolved external symbol __imp__PostThreadMessageA@16 referenced in function