mf/tests: Test IMediaObject_GetOutputSizeInfo.
[wine.git] / dlls / srvsvc / srvsvc.c
blob3b2b563bc6cc2c1cacd90896138b29b70b3141fd
1 /*
2 * LanmanServer Service
4 * Copyright 2022 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winsvc.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(lanman);
30 static SERVICE_STATUS_HANDLE svc_handle;
31 static HANDLE done_event;
33 static void svc_update_status(DWORD state)
35 SERVICE_STATUS status;
37 status.dwServiceType = SERVICE_WIN32;
38 status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
39 status.dwWin32ExitCode = 0;
40 status.dwServiceSpecificExitCode = 0;
41 status.dwCheckPoint = 0;
42 status.dwWaitHint = 0;
43 status.dwCurrentState = state;
45 SetServiceStatus(svc_handle, &status);
48 static void WINAPI svc_handler(DWORD control)
50 TRACE("%#lx\n", control);
52 switch (control)
54 case SERVICE_CONTROL_STOP:
55 case SERVICE_CONTROL_SHUTDOWN:
56 svc_update_status(SERVICE_STOP_PENDING);
57 SetEvent(done_event);
58 break;
60 default:
61 svc_update_status(SERVICE_RUNNING);
62 break;
66 void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
68 TRACE("Starting LanmanServer\n");
70 svc_handle = RegisterServiceCtrlHandlerW(L"LanmanServer", svc_handler);
71 if (!svc_handle)
73 ERR("RegisterServiceCtrlHandler error %ld\n", GetLastError());
74 return;
77 svc_update_status(SERVICE_START_PENDING);
78 done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
80 svc_update_status(SERVICE_RUNNING);
81 WaitForSingleObject(done_event, INFINITE);
82 CloseHandle(done_event);
84 svc_update_status(SERVICE_STOPPED);
86 TRACE("Exiting LanmanServer\n");