Thanks, I found the problem:

I was calling the below function to edit service description (which
TServiceApplication cannot do automatically) in OnStart of the

BOOL ReconfigureService(BOOL fDisable, LPSTR lpDesc, const String
&serviceName) // from
// and
    SC_LOCK sclLock;
    DWORD dwBytesNeeded, dwStartType;
    BOOL bSuccess=TRUE;

    SC_HANDLE schSCManager;
    SC_HANDLE schService;

    // Open a handle to the SC Manager database.

    schSCManager = OpenSCManager(
    NULL,                    // local machine
    NULL,                    // ServicesActive database
    SC_MANAGER_ALL_ACCESS);  // full access rights

    if(NULL == schSCManager)
        return false;

    // Need to acquire database lock before reconfiguring.

    sclLock = LockServiceDatabase(schSCManager);

    // If the database cannot be locked, report the details.

    if (sclLock == NULL)
        // Exit if the database is not locked by another process.

        if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED)
            // printf("LockServiceDatabase failed (%d)\n", GetLastError());
            return FALSE;

        // Allocate a buffer to get details about the lock.

        lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS) LocalAlloc(
            LPTR, sizeof(QUERY_SERVICE_LOCK_STATUS)+256);
        if (lpqslsBuf == NULL)
            // printf("LocalAlloc failed (%d)\n", GetLastError());
            return FALSE;

        // Get and print the lock status information.

        if (!QueryServiceLockStatus(
            &dwBytesNeeded) )
            // printf("QueryServiceLockStatus failed (%d)", GetLastError());
            return FALSE;

        //if (lpqslsBuf->fIsLocked)
            // printf("Locked by: %s, duration: %d seconds\n",
            //    lpqslsBuf->lpLockOwner,
            //    lpqslsBuf->dwLockDuration);
            // printf("No longer locked\n");


    // The database is locked, so it is safe to make changes.

    // Open a handle to the service.

    schService = OpenService(
        schSCManager,           // SCManager database
        serviceName.c_str(),             // name of service
        SERVICE_CHANGE_CONFIG); // need CHANGE access
    if (schService == NULL)
        // printf("OpenService failed (%d)\n", GetLastError());
        return FALSE;

    dwStartType = SERVICE_AUTO_START; //(fDisable) ? SERVICE_DISABLED

    // Make the changes.

    if (! ChangeServiceConfig(
        schService,        // handle of service
        SERVICE_NO_CHANGE, // service type: no change
        dwStartType,       // change service start type
        SERVICE_NO_CHANGE, // error control: no change
        NULL,              // binary path: no change
        NULL,              // load order group: no change
        NULL,              // tag ID: no change
        NULL,              // dependencies: no change
        NULL,              // account name: no change
        NULL,              // password: no change
        NULL) )            // display name: no change
        // printf("ChangeServiceConfig failed (%d)\n", GetLastError());
        bSuccess = FALSE;
        // printf("ChangeServiceConfig succeeded.\n");

    sdBuf.lpDescription = lpDesc;

    if( !ChangeServiceConfig2(
        schService,                 // handle to service
        SERVICE_CONFIG_DESCRIPTION, // change: description
        &sdBuf) )                   // value: new description
        // printf("ChangeServiceConfig2 failed\n");
        bSuccess = FALSE;
        // printf("ChangeServiceConfig2 succeeded\n");

    // Release the database lock.


    // Close the handle to the service.

    return bSuccess;

It simply got the service hanging during system boot if service type
was auto. Just FYI.

BTW, the function is useful in adding the description but it should be
called after install or a few mins.

Best Regards,


On 12/13/06, Arno Garrels <[EMAIL PROTECTED]> wrote:
> Fastream Technologies wrote:
> > Hello,
> >
> > Our clients using Windows 2003 complain that the lastest beta is
> > causing hangs during boot up and then reboots and goes into a loop.
> > This is a HTTP/FTP server installed as system service and running with
> > administrative rights. It depends only to Tcpip. I noticed that when
> > it is trying to run, it blocks alg.exe to execute and this is a cycle
> > of waiting (cyclic dependency).
> You can also specify a LoadGroup, that is the name of the load ordering group
> of which your service is a member. The startup program uses load ordering
> groups to load groups of services in a specified order with respect to the
> other groups. The list of load ordering groups is contained in the following
> registry value: 
> HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder
> Also check value of property ErrorSeverity (dwErrorControl).
> Have you tried a service-depency on RPCSS?
> ---
> Arno Garrels [TeamICS]
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto
> Visit our website at
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to