static USHORT svc_query_ex(SC_HANDLE manager) { /********************************************** * * s v c _ q u e r y _ e x * ********************************************** * * Functional description * Report (print) the status and configuration * of all installed Firebird services. * If none are installed return FB_FAILURE * so as to allow a call to svc_query for the * status of the default instance. * **********************************************/ if (manager == NULL) return FB_FAILURE; DWORD lpServicesReturned = 0; DWORD lpResumeHandle = 0; DWORD pcbBytesNeeded = 0; USHORT rc = FB_FAILURE; EnumServicesStatus(manager, SERVICE_WIN32, SERVICE_STATE_ALL, NULL, 0, &pcbBytesNeeded, &lpServicesReturned, &lpResumeHandle); if ( GetLastError() == ERROR_MORE_DATA ) { const DWORD dwBytes = pcbBytesNeeded + sizeof(ENUM_SERVICE_STATUS); ENUM_SERVICE_STATUS* service_data = FB_NEW ENUM_SERVICE_STATUS [dwBytes]; EnumServicesStatus(manager, SERVICE_WIN32, SERVICE_STATE_ALL, service_data, dwBytes, &pcbBytesNeeded, &lpServicesReturned, &lpResumeHandle); if (lpServicesReturned == 0) delete[] service_data; else { Firebird::string serverServiceName; bool firebirdServicesInstalled = false; for ( DWORD i = 0; i < lpServicesReturned; i++ ) { serverServiceName = service_data[i].lpServiceName; if ( serverServiceName.substr(0, 8) == "Firebird" ) { svc_query(service_data[i].lpServiceName, service_data[i].lpDisplayName, manager); firebirdServicesInstalled = true; } } delete[] service_data; if ( firebirdServicesInstalled ) rc = FB_SUCCESS; else printf("\nNo named Firebird service instances are installed.\n"); } } return rc; }