ReactOS 0.4.16-dev-197-g92996da
name.c File Reference
#include "sc.h"
Include dependency graph for name.c:

Go to the source code of this file.

Functions

BOOL GetDisplayName (LPCTSTR ServiceName)
 
BOOL GetKeyName (LPCTSTR ServiceName)
 

Function Documentation

◆ GetDisplayName()

BOOL GetDisplayName ( LPCTSTR  ServiceName)

Definition at line 12 of file name.c.

13{
14 SC_HANDLE hManager = NULL;
15 BOOL bResult = TRUE;
16 DWORD BufferSize = 0;
18
19 hManager = OpenSCManager(NULL,
20 NULL,
22 if (hManager == NULL)
23 {
24 _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
25 bResult = FALSE;
26 goto done;
27 }
28
29 if (!GetServiceDisplayName(hManager,
31 NULL,
32 &BufferSize))
33 {
34 if (BufferSize == 0)
35 {
36 _tprintf(_T("[SC] GetServiceDisplayName FAILED %lu:\n\n"), GetLastError());
37 bResult = FALSE;
38 goto done;
39 }
40 }
41
42 pBuffer = HeapAlloc(GetProcessHeap(), 0, (BufferSize + 1) * sizeof(TCHAR));
43 if (pBuffer == NULL)
44 {
46 _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError());
47 bResult = FALSE;
48 goto done;
49 }
50
51 BufferSize++;
52 if (!GetServiceDisplayName(hManager,
54 pBuffer,
55 &BufferSize))
56 {
57 _tprintf(_T("[SC] GetServiceDisplayName FAILED %lu:\n\n"), GetLastError());
58 bResult = FALSE;
59 goto done;
60 }
61
62 _tprintf(_T("[SC] GetServiceDisplayName SUCCESS Name = %s\n"), pBuffer);
63
64done:
65 if (bResult == FALSE)
67
68 if (pBuffer != NULL)
70
71 if (hManager)
72 CloseServiceHandle(hManager);
73
74 return bResult;
75}
static WCHAR ServiceName[]
Definition: browser.c:19
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _tprintf
Definition: tchar.h:506
DWORD ReportLastError(void)
Definition: loadlib.c:67
PVOID pBuffer
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define _T(x)
Definition: vfdio.h:22
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define OpenSCManager
Definition: winsvc.h:575
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define GetServiceDisplayName
Definition: winsvc.h:573
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by _test_GetCurMoniker(), DECLARE_INTERFACE_(), Moniker_GetDisplayName(), ScControl(), test_editing_mode(), test_exec_editmode(), test_Hlink_Navigate(), test_HlinkGetSetMonikerReference(), test_HlinkResolveMonikerForData(), test_HlinkSite(), and test_Load().

◆ GetKeyName()

BOOL GetKeyName ( LPCTSTR  ServiceName)

Definition at line 77 of file name.c.

78{
79 SC_HANDLE hManager = NULL;
80 BOOL bResult = TRUE;
81 DWORD BufferSize = 0;
83
84 hManager = OpenSCManager(NULL,
85 NULL,
87 if (hManager == NULL)
88 {
89 _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
90 bResult = FALSE;
91 goto done;
92 }
93
94 if (!GetServiceKeyName(hManager,
96 NULL,
97 &BufferSize))
98 {
99 if (BufferSize == 0)
100 {
101 _tprintf(_T("[SC] GetServiceKeyName FAILED %lu:\n\n"), GetLastError());
102 bResult = FALSE;
103 goto done;
104 }
105 }
106
107 pBuffer = HeapAlloc(GetProcessHeap(), 0, (BufferSize + 1) * sizeof(TCHAR));
108 if (pBuffer == NULL)
109 {
111 _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError());
112 bResult = FALSE;
113 goto done;
114 }
115
116 BufferSize++;
117 if (!GetServiceKeyName(hManager,
119 pBuffer,
120 &BufferSize))
121 {
122 _tprintf(_T("[SC] GetServiceKeyName FAILED %lu:\n\n"), GetLastError());
123 bResult = FALSE;
124 goto done;
125 }
126
127 _tprintf(_T("[SC] GetServiceKeyName SUCCESS Name = %s\n"), pBuffer);
128
129done:
130 if (bResult == FALSE)
132
133 if (pBuffer != NULL)
135
136 if (hManager)
137 CloseServiceHandle(hManager);
138
139 return bResult;
140}
#define GetServiceKeyName
Definition: winsvc.h:574