ReactOS 0.4.15-dev-5666-gc548b97
delete.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/mscutils/servman/delete.c
5 * PURPOSE: Delete an existing service
6 * COPYRIGHT: Copyright 2006-2007 Ged Murphy <gedmurphy@reactos.org>
7 *
8 */
9
10#include "precomp.h"
11
12static BOOL
14 HWND hDlg)
15{
16 SC_HANDLE hSCManager;
17 SC_HANDLE hSc;
18 BOOL bRet = FALSE;
19
21 NULL,
23 if (hSCManager)
24 {
26 Info->pCurrentService->lpServiceName,
27 DELETE);
28 if (hSc)
29 {
30 if (DeleteService(hSc))
31 {
32 LPWSTR lpSuccess;
33
34 /* report success to user */
35 if (AllocAndLoadString(&lpSuccess,
38 {
39 DisplayString(lpSuccess);
40
41 LocalFree(lpSuccess);
42 }
43
44 bRet = TRUE;
45 }
46
48 }
49
51 }
52
53 return bRet;
54}
55
61{
64
65 /* Get the window context */
68 if (Info == NULL && message != WM_INITDIALOG)
69 {
70 return FALSE;
71 }
72
73 switch (message)
74 {
75 case WM_INITDIALOG:
76 {
77 LPWSTR lpDescription;
78
80 if (Info != NULL)
81 {
84 (LONG_PTR)Info);
85
89 16,
90 16,
91 0);
92 if (hIcon)
93 {
94 SendMessageW(hDlg,
95 WM_SETICON,
97 (LPARAM)hIcon);
99 }
100
104 0,
105 (LPARAM)Info->pCurrentService->lpDisplayName);
106
107 lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName);
108 if (lpDescription)
109 {
113 0,
114 (LPARAM)lpDescription);
116 0,
117 lpDescription);
118 }
119
120 return TRUE;
121 }
122
123 return FALSE;
124 }
125
126 case WM_COMMAND:
127 {
128 switch (LOWORD(wParam))
129 {
130 case IDOK:
131 {
132 if (DoDeleteService(Info, hDlg))
133 {
134 (void)ListView_DeleteItem(Info->hListView,
135 Info->SelectedItem);
137 }
138 EndDialog(hDlg,
139 LOWORD(wParam));
140 return TRUE;
141 }
142
143 case IDCANCEL:
144 {
145 EndDialog(hDlg,
146 LOWORD(wParam));
147 return TRUE;
148 }
149 }
150 }
151 }
152
153 return FALSE;
154}
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
INT_PTR CALLBACK DeleteDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: delete.c:57
static BOOL DoDeleteService(PMAIN_WND_INFO Info, HWND hDlg)
Definition: delete.c:13
VOID UpdateServiceCount(PMAIN_WND_INFO Info)
Definition: mainwnd.c:125
VOID DisplayString(LPWSTR Msg)
Definition: misc.c:211
HANDLE ProcessHeap
Definition: servman.c:15
struct _MAIN_WND_INFO * PMAIN_WND_INFO
LPWSTR GetServiceDescription(LPWSTR lpServiceName)
Definition: query.c:135
#define IDC_DEL_NAME
Definition: resource.h:197
#define IDS_DELETE_SUCCESS
Definition: resource.h:200
#define IDI_SM_ICON
Definition: resource.h:64
#define IDC_DEL_DESC
Definition: resource.h:198
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define DELETE
Definition: nt_native.h:57
#define LOWORD(l)
Definition: pedump.c:82
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2411
SC_HANDLE hSCManager
Definition: sc.c:12
BOOL WINAPI DeleteService(SC_HANDLE hService)
Definition: scm.c:921
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2016
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2108
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
Definition: tftpd.h:60
#define ICON_SMALL
Definition: tnclass.cpp:48
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define IDCANCEL
Definition: winuser.h:825
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
#define IDOK
Definition: winuser.h:824
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1607
#define SetWindowLongPtrW
Definition: winuser.h:5336
#define MAKEINTRESOURCE
Definition: winuser.h:591
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
WCHAR * LPWSTR
Definition: xmlstorage.h:184