ReactOS 0.4.16-dev-340-g0540c21
create.c File Reference
#include "precomp.h"
Include dependency graph for create.c:

Go to the source code of this file.

Classes

struct  _CREATE_DATA
 

Typedefs

typedef struct _CREATE_DATA CREATE_DATA
 
typedef struct _CREATE_DATAPCREATE_DATA
 

Functions

static BOOL DoCreate (PCREATE_DATA Data)
 
static LPWSTR GetStringFromDialog (PCREATE_DATA Data, UINT id)
 
static BOOL GetDataFromDialog (PCREATE_DATA Data)
 
static VOID FreeMemory (PCREATE_DATA Data)
 
INT_PTR CALLBACK CreateHelpDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK CreateDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

static BOOL bHelpOpen = FALSE
 

Typedef Documentation

◆ CREATE_DATA

◆ PCREATE_DATA

Function Documentation

◆ CreateDialogProc()

INT_PTR CALLBACK CreateDialogProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 218 of file create.c.

222{
223 HICON hIcon = NULL;
224
225 switch (message)
226 {
227 case WM_INITDIALOG:
228 {
232 16,
233 16,
234 0);
235 if (hIcon)
236 {
237 SendMessage(hDlg,
238 WM_SETICON,
240 (LPARAM)hIcon);
242 }
243
244 return TRUE;
245 }
246
247 case WM_COMMAND:
248 {
249 switch (LOWORD(wParam))
250 {
251 case IDOK:
252 {
254
257 sizeof(CREATE_DATA));
258 if (Data)
259 {
260 Data->hSelf = hDlg;
261
263 {
264 DoCreate(Data);
265 }
266 else
267 {
268 /* Something went wrong, leave the dialog
269 * open so they can try again */
271 break;
272 }
273
275 }
276
277 EndDialog(hDlg,
278 LOWORD(wParam));
279 return TRUE;
280 }
281
282 case IDCANCEL:
283 {
284 EndDialog(hDlg,
285 LOWORD(wParam));
286 return TRUE;
287 }
288
289 case ID_CREATE_HELP:
290 {
291 HWND hHelp;
292
293 if (! bHelpOpen)
294 {
295 hHelp = CreateDialog(hInstance,
297 hDlg,
299 if(hHelp != NULL)
300 {
301 bHelpOpen = TRUE;
302 }
303 }
304 }
305 break;
306 }
307 }
308 }
309
310 return FALSE;
311}
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
static BOOL GetDataFromDialog(PCREATE_DATA Data)
Definition: create.c:112
struct _CREATE_DATA * PCREATE_DATA
static BOOL DoCreate(PCREATE_DATA Data)
Definition: create.c:26
INT_PTR CALLBACK CreateHelpDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: create.c:163
static BOOL bHelpOpen
Definition: create.c:23
HANDLE ProcessHeap
Definition: servman.c:15
#define ID_CREATE_HELP
Definition: resource.h:187
#define IDD_DLG_HELP_OPTIONS
Definition: resource.h:188
#define IDI_SM_ICON
Definition: resource.h:64
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define LOWORD(l)
Definition: pedump.c:82
Definition: tftpd.h:60
#define ICON_SMALL
Definition: tnclass.cpp:48
LONG_PTR LPARAM
Definition: windef.h:208
#define IDCANCEL
Definition: winuser.h:834
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_COMMAND
Definition: winuser.h:1743
#define CreateDialog
Definition: winuser.h:5761
#define WM_INITDIALOG
Definition: winuser.h:1742
#define IDOK
Definition: winuser.h:833
#define SendMessage
Definition: winuser.h:5855
#define LoadImage
Definition: winuser.h:5827
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105

Referenced by MainWndCommand().

◆ CreateHelpDialogProc()

INT_PTR CALLBACK CreateHelpDialogProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 163 of file create.c.

167{
168 HWND hHelp;
169 HICON hIcon = NULL;
170 WCHAR Buf[1000];
171
172 switch (message)
173 {
174 case WM_INITDIALOG:
175 {
179 16,
180 16,
181 0);
182
183 SendMessageW(hDlg,
184 WM_SETICON,
186 (LPARAM)hIcon);
187
188 hHelp = GetDlgItem(hDlg,
190
193 Buf,
194 sizeof(Buf) / sizeof(WCHAR));
195
196 SetWindowTextW(hHelp, Buf);
197
198 return TRUE;
199 }
200
201 case WM_COMMAND:
202 {
203 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
204 {
207 DestroyWindow(hDlg);
208 return TRUE;
209 }
210 break;
211 }
212 }
213
214 return FALSE;
215}
#define IDS_HELP_OPTIONS
Definition: resource.h:190
#define IDC_CREATE_HELP
Definition: resource.h:189
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2255
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreateDialogProc().

◆ DoCreate()

static BOOL DoCreate ( PCREATE_DATA  Data)
static

Definition at line 26 of file create.c.

27{
28 SC_HANDLE hSCManager;
29 SC_HANDLE hSc;
30 BOOL bRet = FALSE;
31
32 /* open handle to the SCM */
34 NULL,
36 if (hSCManager)
37 {
39 Data->ServiceName,
40 Data->DisplayName,
45 Data->BinPath,
46 NULL,
47 NULL,
48 NULL,
49 NULL,
50 NULL);
51
52 if (hSc)
53 {
54 LPWSTR lpSuccess;
55
56 /* Set the service description as CreateService
57 does not do this for us */
58 SetServiceDescription(Data->ServiceName,
59 Data->Description);
60
61 /* report success to user */
62 if (AllocAndLoadString(&lpSuccess,
65 {
66 DisplayString(lpSuccess);
67
68 LocalFree(lpSuccess);
69 }
70
72 bRet = TRUE;
73 }
74
76 }
77
78 return bRet;
79}
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
VOID DisplayString(LPWSTR Msg)
Definition: misc.c:211
BOOL SetServiceDescription(LPWSTR lpServiceName, LPWSTR lpDescription)
Definition: query.c:210
#define IDS_CREATE_SUCCESS
Definition: resource.h:191
unsigned int BOOL
Definition: ntddk_ex.h:94
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
SC_HANDLE hSCManager
Definition: sc.c:12
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
SC_HANDLE WINAPI CreateServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword)
Definition: scm.c:812
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define SERVICE_ALL_ACCESS
Definition: winsvc.h:62
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
#define SERVICE_DEMAND_START
Definition: cmtypes.h:978
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962
#define SERVICE_ERROR_NORMAL
Definition: cmtypes.h:982
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CreateDialogProc().

◆ FreeMemory()

static VOID FreeMemory ( PCREATE_DATA  Data)
static

Definition at line 134 of file create.c.

135{
136 if (Data->ServiceName != NULL)
138 0,
139 Data->ServiceName);
140 if (Data->DisplayName != NULL)
142 0,
143 Data->DisplayName);
144 if (Data->BinPath != NULL)
146 0,
147 Data->BinPath);
148 if (Data->Description != NULL)
150 0,
151 Data->Description);
152 if (Data->Options != NULL)
154 0,
155 Data->Options);
156
158 0,
159 Data);
160}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by CompleteIO(), CreateDialogProc(), CreateSoundThread(), DestroySoundThread(), DetectNt4SoundDevices(), DoWaveStreaming(), EnumerateNt4ServiceSoundDevices(), FreeSoundDevice(), FreeSoundDeviceInstance(), KmtFltSendBufferToDriver(), OpenSoundDeviceRegKey(), OpenSoundDriverParametersRegKey(), and UnprepareWaveHeader().

◆ GetDataFromDialog()

static BOOL GetDataFromDialog ( PCREATE_DATA  Data)
static

Definition at line 112 of file create.c.

113{
114 BOOL bRet = FALSE;
115
116 if ((Data->ServiceName = GetStringFromDialog(Data, IDC_CREATE_SERVNAME)))
117 {
118 if ((Data->DisplayName = GetStringFromDialog(Data, IDC_CREATE_DISPNAME)))
119 {
120 if ((Data->BinPath = GetStringFromDialog(Data, IDC_CREATE_PATH)))
121 {
124
125 bRet = TRUE;
126 }
127 }
128 }
129
130 return bRet;
131}
static LPWSTR GetStringFromDialog(PCREATE_DATA Data, UINT id)
Definition: create.c:82
#define IDC_CREATE_DISPNAME
Definition: resource.h:183
#define IDC_CREATE_SERVNAME
Definition: resource.h:182
#define IDC_CREATE_DESC
Definition: resource.h:185
#define IDC_CREATE_OPTIONS
Definition: resource.h:186
#define IDC_CREATE_PATH
Definition: resource.h:184

Referenced by CreateDialogProc().

◆ GetStringFromDialog()

static LPWSTR GetStringFromDialog ( PCREATE_DATA  Data,
UINT  id 
)
static

Definition at line 82 of file create.c.

84{
85 HWND hwnd;
86 LPWSTR lpString = NULL;
87 INT iLen = 0;
88
89 hwnd = GetDlgItem(Data->hSelf,
90 id);
91 if (hwnd)
92 {
94 if (iLen)
95 {
96 lpString = (LPWSTR)HeapAlloc(ProcessHeap,
97 0,
98 (iLen + 1) * sizeof(WCHAR));
99 if (lpString)
100 {
102 lpString,
103 iLen + 1);
104 }
105 }
106 }
107
108 return lpString;
109}
int32_t INT
Definition: typedefs.h:58
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI GetWindowTextLengthW(_In_ HWND)

Referenced by GetDataFromDialog().

Variable Documentation

◆ bHelpOpen

BOOL bHelpOpen = FALSE
static

Definition at line 23 of file create.c.

Referenced by CreateDialogProc(), and CreateHelpDialogProc().