c++ - create service on windows -


I'm having trouble starting my service on my PC. My code is based on this article

When I call installservice from my int main (int argil, four * argv [], it is registered successfully (I can see it in msconfig and services.msc). Although it has not started. I start the service manually through the services. MSV and I get the error "TRI T2: The system can not find the specified file. "Why is it? I did not register the services again a minute ago, my external HD is still running (where it is currently stored. I'm going to take a nondev version of what I'm doing wrong and I can see another tutorial I can see (I only got a link from Google)

  #define srvName "MyTestService_01312009" Zero Installation Service (Four * Path) {SC_HANDLE handle = :: O PenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS); SC_HANDLE service = :: CreateService (handle, srvName, "MyTestService_01312009b", GENERIC_READ | GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, path, zero, zero, zero zero zero); } Uninstall the zero service () {SC_HANDLE handle = :: OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS); //? SC_HANDLE service = :: Open service (handle, SRVName, DELETE); If (service! = Null) {// remove service! :: Removal service (service); }} SERVICE_STATUS_HANDLE hStatus; SERVICE_STATUS status; / * If (:: StartServiceCtrlDispatcher (dispatchTable) == 0) {// If this fails, then perhaps it is possible because someone has started the command line from us // "use"} print the message saying * / ZERO WINAPI ServiceCtrlHandler (DWORD CONTROL) {SWITCH (CONTROL) {CASES SERVICE_CONTROL_SHUTDOWN: CASE SERVICE_CONTROL_STOP: // Do the closed things here: status.dwCurrentState = SERVICE_STOPPED; Status.dwWin32ExitCode = 0; Status.dwCheckPoint = 0; Status.dwWaitHint = 0; break; Cases SERVICE_CONTROL_INTERROGATE: // whatever the current situation is ... break; } :: Setsstestats (Hastates, and Status); } ZERO WINAPI ServiceDispatch (DWORD numArgs, four ** args) {// We are starting service-specific stuff memset (& amp; position, 0, sizeof (SERVICE_STATUS)); Status.dwServiceType = SERVICE_WIN32; Status.dwCurrentState = SERVICE_START_PENDING; Status.dwControls accepted = SERVICE_ACCEPT_STOP; HStatus = :: RegisterServiceCtrlHandler (srvName, and ServiceCtrlHandler); // More initial stuff here FILE * f = fopen ("c: /testSrv.bin", "wb"); :: Setting Stave (Hustats, and Status); } SERVICE_TABLE_ENTRY Transmitter [] = {{srvName, and Service Dispatch}, {NULL, NULL}};  

Maybe you can use to find out what's wrong.

Start this, and the name is not found The result is that the service is looking to be in relation to the start.


Comments