bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / remotecontrol / mDNSResponder / dllmain.c
blob49fd854c96c89b437e10c60ba81939287815dea6
1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 // #include <windows.h>
19 #include <DebugServices.h>
20 #include <stdlib.h>
22 BOOL APIENTRY DllMain( HANDLE inModule, DWORD inReason, LPVOID inReserved )
24 (void) inModule;
25 (void) inReserved;
27 switch( inReason )
29 case DLL_PROCESS_ATTACH:
30 case DLL_THREAD_ATTACH:
31 case DLL_THREAD_DETACH:
32 case DLL_PROCESS_DETACH:
33 break;
35 return TRUE;
39 BOOL
40 IsSystemServiceDisabled()
42 ENUM_SERVICE_STATUS * lpService = NULL;
43 SC_HANDLE sc;
44 BOOL ret = FALSE;
45 BOOL ok;
46 DWORD bytesNeeded = 0;
47 DWORD srvCount;
48 DWORD resumeHandle = 0;
49 DWORD srvType;
50 DWORD srvState;
51 DWORD dwBytes = 0;
52 DWORD i;
53 OSStatus err;
55 sc = OpenSCManager( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE );
56 err = translate_errno( sc, GetLastError(), kUnknownErr );
57 require_noerr( err, exit );
59 srvType = SERVICE_WIN32;
60 srvState = SERVICE_STATE_ALL;
62 for ( ;; )
64 // Call EnumServicesStatus using the handle returned by OpenSCManager
66 ok = EnumServicesStatus ( sc, srvType, srvState, lpService, dwBytes, &bytesNeeded, &srvCount, &resumeHandle );
68 if ( ok || ( GetLastError() != ERROR_MORE_DATA ) )
70 break;
73 if ( lpService )
75 free( lpService );
78 dwBytes = bytesNeeded;
80 lpService = ( ENUM_SERVICE_STATUS* ) malloc( dwBytes );
81 require_action( lpService, exit, ret = FALSE );
84 err = translate_errno( ok, GetLastError(), kUnknownErr );
85 require_noerr( err, exit );
87 for ( i = 0; i < srvCount; i++ )
89 if ( strcmp( lpService[i].lpServiceName, "Bonjour Service" ) == 0 )
91 if ( ( lpService[i].ServiceStatus.dwCurrentState == SERVICE_PAUSED ) || ( lpService[i].ServiceStatus.dwCurrentState == SERVICE_STOPPED ) )
93 ret = TRUE;
96 break;
100 exit:
102 if ( lpService )
104 free( lpService );
107 if ( sc )
109 CloseServiceHandle ( sc );
112 return ret;