2006-11-08 11:47:44 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Services
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2007-08-30 12:27:11 +00:00
|
|
|
* FILE: base/applications/mscutils/servman/delete.c
|
2006-11-08 11:47:44 +00:00
|
|
|
* PURPOSE: Delete an existing service
|
2007-08-30 12:27:11 +00:00
|
|
|
* COPYRIGHT: Copyright 2006-2007 Ged Murphy <gedmurphy@reactos.org>
|
2006-11-08 11:47:44 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
DoDeleteService(PMAIN_WND_INFO Info,
|
|
|
|
HWND hDlg)
|
|
|
|
{
|
|
|
|
SC_HANDLE hSCManager;
|
|
|
|
SC_HANDLE hSc;
|
2007-08-30 12:27:11 +00:00
|
|
|
BOOL bRet = FALSE;
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2015-10-26 23:15:40 +00:00
|
|
|
hSCManager = OpenSCManagerW(NULL,
|
|
|
|
NULL,
|
|
|
|
SC_MANAGER_ALL_ACCESS);
|
2007-08-30 12:27:11 +00:00
|
|
|
if (hSCManager)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2015-10-26 23:15:40 +00:00
|
|
|
hSc = OpenServiceW(hSCManager,
|
|
|
|
Info->pCurrentService->lpServiceName,
|
|
|
|
DELETE);
|
2007-08-30 12:27:11 +00:00
|
|
|
if (hSc)
|
|
|
|
{
|
|
|
|
if (DeleteService(hSc))
|
|
|
|
{
|
2015-04-08 17:30:38 +00:00
|
|
|
LPWSTR lpSuccess;
|
2007-08-31 08:21:47 +00:00
|
|
|
|
|
|
|
/* report success to user */
|
|
|
|
if (AllocAndLoadString(&lpSuccess,
|
|
|
|
hInstance,
|
|
|
|
IDS_DELETE_SUCCESS))
|
|
|
|
{
|
|
|
|
DisplayString(lpSuccess);
|
|
|
|
|
2014-04-05 22:31:19 +00:00
|
|
|
LocalFree(lpSuccess);
|
2007-08-31 08:21:47 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 12:27:11 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2007-08-30 12:27:11 +00:00
|
|
|
CloseServiceHandle(hSc);
|
|
|
|
}
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
CloseServiceHandle(hSCManager);
|
|
|
|
}
|
|
|
|
|
2007-08-30 12:27:11 +00:00
|
|
|
return bRet;
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
Merge 34758, 34771, 34786, 34787, 34906, 35826, 36174, 36274, 36444, 36445, 36446, 36447, 36448, 36477, 36511, 36898, 36903 from amd64 branch
svn path=/trunk/; revision=37910
2008-12-07 12:11:46 +00:00
|
|
|
INT_PTR CALLBACK
|
2006-11-08 11:47:44 +00:00
|
|
|
DeleteDialogProc(HWND hDlg,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
PMAIN_WND_INFO Info = NULL;
|
|
|
|
HICON hIcon = NULL;
|
2007-08-30 12:27:11 +00:00
|
|
|
|
|
|
|
/* Get the window context */
|
|
|
|
Info = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg,
|
|
|
|
GWLP_USERDATA);
|
|
|
|
if (Info == NULL && message != WM_INITDIALOG)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2015-04-08 17:30:38 +00:00
|
|
|
LPWSTR lpDescription;
|
2007-08-30 12:27:11 +00:00
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
Info = (PMAIN_WND_INFO)lParam;
|
2007-08-30 12:27:11 +00:00
|
|
|
if (Info != NULL)
|
|
|
|
{
|
2015-04-08 17:30:38 +00:00
|
|
|
SetWindowLongPtrW(hDlg,
|
|
|
|
GWLP_USERDATA,
|
|
|
|
(LONG_PTR)Info);
|
|
|
|
|
|
|
|
hIcon = (HICON)LoadImageW(hInstance,
|
|
|
|
MAKEINTRESOURCE(IDI_SM_ICON),
|
|
|
|
IMAGE_ICON,
|
|
|
|
16,
|
|
|
|
16,
|
|
|
|
0);
|
2007-08-30 12:27:11 +00:00
|
|
|
if (hIcon)
|
|
|
|
{
|
2015-04-08 17:30:38 +00:00
|
|
|
SendMessageW(hDlg,
|
|
|
|
WM_SETICON,
|
|
|
|
ICON_SMALL,
|
|
|
|
(LPARAM)hIcon);
|
2007-08-30 12:27:11 +00:00
|
|
|
DestroyIcon(hIcon);
|
|
|
|
}
|
|
|
|
|
2015-04-08 17:30:38 +00:00
|
|
|
SendDlgItemMessageW(hDlg,
|
|
|
|
IDC_DEL_NAME,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)Info->pCurrentService->lpDisplayName);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2007-08-30 12:27:11 +00:00
|
|
|
lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName);
|
|
|
|
if (lpDescription)
|
|
|
|
{
|
2015-04-08 17:30:38 +00:00
|
|
|
SendDlgItemMessageW(hDlg,
|
|
|
|
IDC_DEL_DESC,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)lpDescription);
|
2007-08-30 12:27:11 +00:00
|
|
|
HeapFree(ProcessHeap,
|
|
|
|
0,
|
|
|
|
lpDescription);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
{
|
|
|
|
if (DoDeleteService(Info, hDlg))
|
2007-08-30 13:39:59 +00:00
|
|
|
{
|
2006-11-08 11:47:44 +00:00
|
|
|
(void)ListView_DeleteItem(Info->hListView,
|
|
|
|
Info->SelectedItem);
|
2007-08-30 13:39:59 +00:00
|
|
|
UpdateServiceCount(Info);
|
|
|
|
}
|
2006-11-08 11:47:44 +00:00
|
|
|
EndDialog(hDlg,
|
|
|
|
LOWORD(wParam));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
{
|
|
|
|
EndDialog(hDlg,
|
|
|
|
LOWORD(wParam));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|