ReactOS  0.4.12-dev-36-g472787f
delete.c File Reference
#include "precomp.h"
Include dependency graph for delete.c:

Go to the source code of this file.

Functions

static BOOL DoDeleteService (PMAIN_WND_INFO Info, HWND hDlg)
 
INT_PTR CALLBACK DeleteDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ DeleteDialogProc()

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

Definition at line 57 of file delete.c.

Referenced by MainWndCommand().

61 {
63  HICON hIcon = NULL;
64 
65  /* Get the window context */
66  Info = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg,
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 
79  Info = (PMAIN_WND_INFO)lParam;
80  if (Info != NULL)
81  {
82  SetWindowLongPtrW(hDlg,
84  (LONG_PTR)Info);
85 
86  hIcon = (HICON)LoadImageW(hInstance,
88  IMAGE_ICON,
89  16,
90  16,
91  0);
92  if (hIcon)
93  {
94  SendMessageW(hDlg,
95  WM_SETICON,
96  ICON_SMALL,
97  (LPARAM)hIcon);
98  DestroyIcon(hIcon);
99  }
100 
101  SendDlgItemMessageW(hDlg,
102  IDC_DEL_NAME,
103  WM_SETTEXT,
104  0,
106 
107  lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName);
108  if (lpDescription)
109  {
110  SendDlgItemMessageW(hDlg,
111  IDC_DEL_DESC,
112  WM_SETTEXT,
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  {
135  Info->SelectedItem);
136  UpdateServiceCount(Info);
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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IMAGE_ICON
Definition: winuser.h:212
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
LPWSTR GetServiceDescription(LPWSTR lpServiceName)
Definition: query.c:135
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
VOID UpdateServiceCount(PMAIN_WND_INFO Info)
Definition: mainwnd.c:124
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
struct TraceInfo Info
INT SelectedItem
Definition: precomp.h:60
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
Definition: charmap.c:20
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
LONG_PTR LPARAM
Definition: windef.h:208
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2381
#define WM_SETTEXT
Definition: winuser.h:1599
struct _MAIN_WND_INFO * PMAIN_WND_INFO
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_DEL_DESC
Definition: resource.h:200
#define IDC_DEL_NAME
Definition: resource.h:199
#define WM_COMMAND
Definition: winuser.h:1716
HANDLE ProcessHeap
Definition: servman.c:15
HICON hIcon
Definition: msconfig.c:44
ENUM_SERVICE_STATUS_PROCESS * pCurrentService
Definition: precomp.h:57
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDI_SM_ICON
Definition: resource.h:66
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define GetWindowLongPtr
Definition: treelist.c:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
HWND hListView
Definition: precomp.h:49
static BOOL DoDeleteService(PMAIN_WND_INFO Info, HWND hDlg)
Definition: delete.c:13

◆ DoDeleteService()

static BOOL DoDeleteService ( PMAIN_WND_INFO  Info,
HWND  hDlg 
)
static

Definition at line 13 of file delete.c.

Referenced by DeleteDialogProc().

15 {
16  SC_HANDLE hSCManager;
17  SC_HANDLE hSc;
18  BOOL bRet = FALSE;
19 
20  hSCManager = OpenSCManagerW(NULL,
21  NULL,
23  if (hSCManager)
24  {
25  hSc = OpenServiceW(hSCManager,
27  DELETE);
28  if (hSc)
29  {
30  if (DeleteService(hSc))
31  {
32  LPWSTR lpSuccess;
33 
34  /* report success to user */
35  if (AllocAndLoadString(&lpSuccess,
36  hInstance,
38  {
39  DisplayString(lpSuccess);
40 
41  LocalFree(lpSuccess);
42  }
43 
44  bRet = TRUE;
45  }
46 
47  CloseServiceHandle(hSc);
48  }
49 
50  CloseServiceHandle(hSCManager);
51  }
52 
53  return bRet;
54 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DeleteService(SC_HANDLE hService)
Definition: scm.c:915
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
HINSTANCE hInstance
Definition: charmap.c:20
#define IDS_DELETE_SUCCESS
Definition: resource.h:202
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2102
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2010
VOID DisplayString(LPWSTR Msg)
Definition: misc.c:211
SC_HANDLE hSCManager
Definition: sc.c:12
ENUM_SERVICE_STATUS_PROCESS * pCurrentService
Definition: precomp.h:57
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define DELETE
Definition: nt_native.h:57