fix setting of the description when creating services Modified: trunk/reactos/base/system/servman/create.c Modified: trunk/reactos/base/system/servman/query.c Modified: trunk/reactos/base/system/servman/servman.h _____
Modified: trunk/reactos/base/system/servman/create.c --- trunk/reactos/base/system/servman/create.c 2006-02-03 20:03:48 UTC (rev 76) +++ trunk/reactos/base/system/servman/create.c 2006-02-03 20:38:07 UTC (rev 77) @@ -20,9 +20,6 @@
{ SC_HANDLE hSCManager; SC_HANDLE hSc; - HKEY hKey; - LPCTSTR Path = _T("System\CurrentControlSet\Services\%s"); - TCHAR buf[300];
/* open handle to the SCM */ hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); @@ -52,19 +49,8 @@ return FALSE; }
+ SetDescription(ServiceName, Description);
- - /* open the registry key for the service */ - /* TODO: move all this into query */ - _sntprintf(buf, sizeof(buf) / sizeof(TCHAR), Path, ServiceName); - RegOpenKeyEx(HKEY_LOCAL_MACHINE, - buf, - 0, - KEY_READ, - &hKey); - - SetDescription(hKey, &Description); - DisplayString(_T("Service Succesfully Created")); CloseServiceHandle(hSCManager); CloseServiceHandle(hSc); @@ -144,7 +130,6 @@ if (ServiceName != NULL) { GetWindowText(hwnd, ServiceName, iLen+1); - DisplayString(ServiceName); }
} @@ -175,7 +160,7 @@
/* get description */ iLen = 0; - hwnd = GetDlgItem(hDlg, IDC_CREATE_PATH); + hwnd = GetDlgItem(hDlg, IDC_CREATE_DESC); iLen = GetWindowTextLength(hwnd); if (iLen != 0) { _____
Modified: trunk/reactos/base/system/servman/query.c --- trunk/reactos/base/system/servman/query.c 2006-02-03 20:03:48 UTC (rev 76) +++ trunk/reactos/base/system/servman/query.c 2006-02-03 20:38:07 UTC (rev 77) @@ -43,23 +43,42 @@
/* Sets the service description in the registry */ -BOOL SetDescription(HKEY hKey, LPTSTR *Description) +BOOL SetDescription(LPTSTR ServiceName, LPTSTR Description) { - TCHAR szBuf[MAX_PATH]; + HKEY hKey; + LPCTSTR Path = _T("System\CurrentControlSet\Services\%s"); + TCHAR buf[300]; + TCHAR szBuf[MAX_PATH]; + LONG val;
- if (RegSetValueEx(hKey, - L"Description", + + /* open the registry key for the service */ + _sntprintf(buf, sizeof(buf) / sizeof(TCHAR), Path, ServiceName); + RegOpenKeyEx(HKEY_LOCAL_MACHINE, + buf, + 0, + KEY_WRITE, + &hKey); + + + if ((val = RegSetValueEx(hKey, + _T("Description"), 0, REG_SZ, (LPBYTE)Description, - (DWORD)lstrlen(szBuf)+1)) - GetError(0); + (DWORD)lstrlen(szBuf)+1)) != ERROR_SUCCESS) + { + GetError(val); + return FALSE; + }
RegCloseKey(hKey); return TRUE; }
+ + /* Retrives the service description from the registry */ BOOL GetDescription(LPTSTR lpServiceName, LPTSTR *retDescription) { _____
Modified: trunk/reactos/base/system/servman/servman.h --- trunk/reactos/base/system/servman/servman.h 2006-02-03 20:03:48 UTC (rev 76) +++ trunk/reactos/base/system/servman/servman.h 2006-02-03 20:38:07 UTC (rev 77) @@ -31,7 +31,7 @@
VOID FreeMemory(VOID); VOID DisplayString(PTCHAR);
-BOOL SetDescription(HKEY, LPTSTR *); +BOOL SetDescription(LPTSTR, LPTSTR); BOOL GetDescription(LPTSTR, LPTSTR *); BOOL GetExecutablePath(LPTSTR *);