SC_HANDLE schSCManager;
schSCManager=OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(schSCManager) {
SC_HANDLE schService=CreateService(
schSCManager, // SCManager database
SZSERVICENAME, // name of service
SZSERVICEDISPLAYNAME, // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
ExePath, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
SZDEPENDENCIES, // dependencies
NULL, // LocalSystem account
NULL); // no password