Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendelete.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Services 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/applications/mscutils/servman/delete.c 00005 * PURPOSE: Delete an existing service 00006 * COPYRIGHT: Copyright 2006-2007 Ged Murphy <gedmurphy@reactos.org> 00007 * 00008 */ 00009 00010 #include "precomp.h" 00011 00012 static BOOL 00013 DoDeleteService(PMAIN_WND_INFO Info, 00014 HWND hDlg) 00015 { 00016 SC_HANDLE hSCManager; 00017 SC_HANDLE hSc; 00018 BOOL bRet = FALSE; 00019 00020 hSCManager = OpenSCManager(NULL, 00021 NULL, 00022 SC_MANAGER_ALL_ACCESS); 00023 if (hSCManager) 00024 { 00025 hSc = OpenService(hSCManager, 00026 Info->pCurrentService->lpServiceName, 00027 DELETE); 00028 if (hSc) 00029 { 00030 if (DeleteService(hSc)) 00031 { 00032 LPTSTR lpSuccess; 00033 00034 /* report success to user */ 00035 if (AllocAndLoadString(&lpSuccess, 00036 hInstance, 00037 IDS_DELETE_SUCCESS)) 00038 { 00039 DisplayString(lpSuccess); 00040 00041 HeapFree(ProcessHeap, 00042 0, 00043 lpSuccess); 00044 } 00045 00046 bRet = TRUE; 00047 } 00048 00049 CloseServiceHandle(hSc); 00050 } 00051 00052 CloseServiceHandle(hSCManager); 00053 } 00054 00055 return bRet; 00056 } 00057 00058 00059 INT_PTR CALLBACK 00060 DeleteDialogProc(HWND hDlg, 00061 UINT message, 00062 WPARAM wParam, 00063 LPARAM lParam) 00064 { 00065 PMAIN_WND_INFO Info = NULL; 00066 HICON hIcon = NULL; 00067 00068 /* Get the window context */ 00069 Info = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg, 00070 GWLP_USERDATA); 00071 if (Info == NULL && message != WM_INITDIALOG) 00072 { 00073 return FALSE; 00074 } 00075 00076 switch (message) 00077 { 00078 case WM_INITDIALOG: 00079 { 00080 LPTSTR lpDescription; 00081 00082 Info = (PMAIN_WND_INFO)lParam; 00083 if (Info != NULL) 00084 { 00085 SetWindowLongPtr(hDlg, 00086 GWLP_USERDATA, 00087 (LONG_PTR)Info); 00088 00089 hIcon = (HICON)LoadImage(hInstance, 00090 MAKEINTRESOURCE(IDI_SM_ICON), 00091 IMAGE_ICON, 00092 16, 00093 16, 00094 0); 00095 if (hIcon) 00096 { 00097 SendMessage(hDlg, 00098 WM_SETICON, 00099 ICON_SMALL, 00100 (LPARAM)hIcon); 00101 DestroyIcon(hIcon); 00102 } 00103 00104 SendDlgItemMessage(hDlg, 00105 IDC_DEL_NAME, 00106 WM_SETTEXT, 00107 0, 00108 (LPARAM)Info->pCurrentService->lpDisplayName); 00109 00110 lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName); 00111 if (lpDescription) 00112 { 00113 SendDlgItemMessage(hDlg, 00114 IDC_DEL_DESC, 00115 WM_SETTEXT, 00116 0, 00117 (LPARAM)lpDescription); 00118 HeapFree(ProcessHeap, 00119 0, 00120 lpDescription); 00121 } 00122 00123 return TRUE; 00124 } 00125 00126 return FALSE; 00127 } 00128 00129 case WM_COMMAND: 00130 { 00131 switch (LOWORD(wParam)) 00132 { 00133 case IDOK: 00134 { 00135 if (DoDeleteService(Info, hDlg)) 00136 { 00137 (void)ListView_DeleteItem(Info->hListView, 00138 Info->SelectedItem); 00139 UpdateServiceCount(Info); 00140 } 00141 EndDialog(hDlg, 00142 LOWORD(wParam)); 00143 return TRUE; 00144 } 00145 00146 case IDCANCEL: 00147 { 00148 EndDialog(hDlg, 00149 LOWORD(wParam)); 00150 return TRUE; 00151 } 00152 } 00153 } 00154 } 00155 00156 return FALSE; 00157 } Generated on Sat May 26 2012 04:15:53 for ReactOS by
1.7.6.1
|