none
What is the difference between a Windows Service and Process RRS feed

Answers

  • Windows services are either separate processes or are part of a system supplied process.  The biggest difference is that main() in a service process invokes things through StartServiceCtrlDispatcher.   One common technique is to construct main() to allow the code to run as a process or a service, for example in the following if you ran the program with an argument it ran as a normal program:

    void __cdecl main(int argc, char **argv)
    {
        SERVICE_TABLE_ENTRY dispatchTable[] =
        {
            { (char *) SERVICENAME, 
              (LPSERVICE_MAIN_FUNCTION ) ServiceMain },
            { NULL, NULL }
        };
    
        if ( argc > 1 )
        {
            DebugService = TRUE;
            ServiceMain( (DWORD) argc, argv );
            exit(0);
        }
    
        if ( !StartServiceCtrlDispatcher ( dispatchTable ) )
        {
        }
    }


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Thursday, April 21, 2016 1:15 PM

All replies

  • Windows services are either separate processes or are part of a system supplied process.  The biggest difference is that main() in a service process invokes things through StartServiceCtrlDispatcher.   One common technique is to construct main() to allow the code to run as a process or a service, for example in the following if you ran the program with an argument it ran as a normal program:

    void __cdecl main(int argc, char **argv)
    {
        SERVICE_TABLE_ENTRY dispatchTable[] =
        {
            { (char *) SERVICENAME, 
              (LPSERVICE_MAIN_FUNCTION ) ServiceMain },
            { NULL, NULL }
        };
    
        if ( argc > 1 )
        {
            DebugService = TRUE;
            ServiceMain( (DWORD) argc, argv );
            exit(0);
        }
    
        if ( !StartServiceCtrlDispatcher ( dispatchTable ) )
        {
        }
    }


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Thursday, April 21, 2016 1:15 PM
  • a service is a part of a normal process. the main difference is the context in which the service runs and that the service's run state can be controlled outside of the service

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, April 21, 2016 4:35 PM