aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/svcutil.cpp
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-09-03 11:22:38 -0700
committerRob Mensching <rob@firegiant.com>2017-09-03 13:33:33 -0700
commit5d8375007754101ff2889d0e79486c8f9b7cf5ab (patch)
treea76d6fb6a38dd9f04a93ffcfd9d64e76779b3414 /src/dutil/svcutil.cpp
parent8e8da6dbc051ec884b5d439bb4f44dc027d05bbf (diff)
downloadwix-5d8375007754101ff2889d0e79486c8f9b7cf5ab.tar.gz
wix-5d8375007754101ff2889d0e79486c8f9b7cf5ab.tar.bz2
wix-5d8375007754101ff2889d0e79486c8f9b7cf5ab.zip
Initial commit
Diffstat (limited to 'src/dutil/svcutil.cpp')
-rw-r--r--src/dutil/svcutil.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/dutil/svcutil.cpp b/src/dutil/svcutil.cpp
new file mode 100644
index 00000000..9da2b5b3
--- /dev/null
+++ b/src/dutil/svcutil.cpp
@@ -0,0 +1,44 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
4
5/********************************************************************
6SvcQueryConfig - queries the configuration of a service
7
8********************************************************************/
9extern "C" HRESULT DAPI SvcQueryConfig(
10 __in SC_HANDLE sch,
11 __out QUERY_SERVICE_CONFIGW** ppConfig
12 )
13{
14 HRESULT hr = S_OK;
15 QUERY_SERVICE_CONFIGW* pConfig = NULL;
16 DWORD cbConfig = 0;
17
18 if (!::QueryServiceConfigW(sch, NULL, 0, &cbConfig))
19 {
20 DWORD er = ::GetLastError();
21 if (ERROR_INSUFFICIENT_BUFFER == er)
22 {
23 pConfig = static_cast<QUERY_SERVICE_CONFIGW*>(MemAlloc(cbConfig, TRUE));
24 ExitOnNull(pConfig, hr, E_OUTOFMEMORY, "Failed to allocate memory to get configuration.");
25
26 if (!::QueryServiceConfigW(sch, pConfig, cbConfig, &cbConfig))
27 {
28 ExitWithLastError(hr, "Failed to read service configuration.");
29 }
30 }
31 else
32 {
33 ExitOnWin32Error(er, hr, "Failed to query service configuration.");
34 }
35 }
36
37 *ppConfig = pConfig;
38 pConfig = NULL;
39
40LExit:
41 ReleaseMem(pConfig);
42
43 return hr;
44}