pull service info out of the registry to populate the list view Modified: trunk/reactos/subsys/system/servman/En.rc Modified: trunk/reactos/subsys/system/servman/query.c Modified: trunk/reactos/subsys/system/servman/res/system.ico Modified: trunk/reactos/subsys/system/servman/resource.h _____
Modified: trunk/reactos/subsys/system/servman/En.rc --- trunk/reactos/subsys/system/servman/En.rc 2006-01-07 01:06:48 UTC (rev 20635) +++ trunk/reactos/subsys/system/servman/En.rc 2006-01-07 01:14:38 UTC (rev 20636) @@ -82,6 +82,9 @@
IDS_SERVICES_STATUS_STOPPED "Stopped" IDS_SERVICES_YES "Yes" IDS_SERVICES_UNKNOWN "Unknown" + IDS_SERVICES_AUTO "Automatic" + IDS_SERVICES_MAN "Manual" + IDS_SERVICES_DIS "Disabled" END
STRINGTABLE DISCARDABLE _____
Modified: trunk/reactos/subsys/system/servman/query.c --- trunk/reactos/subsys/system/servman/query.c 2006-01-07 01:06:48 UTC (rev 20635) +++ trunk/reactos/subsys/system/servman/query.c 2006-01-07 01:14:38 UTC (rev 20636) @@ -47,12 +47,31 @@
_stprintf(buf, szNumServices, NumServices); SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);
+ for (Index = 0; Index < NumServices; Index++) { HKEY hKey = NULL; - TCHAR Description[5000]; - DWORD Size = 5000; + LPTSTR Description = NULL; + LONG ret; + LPTSTR LogOnAs = NULL; + DWORD StartUp = 0; + DWORD dwValueSize;
+ /* open the registry key for the service */ + _stprintf(buf, _T("System\CurrentControlSet\Services\%s"), + pServiceStatus[Index].lpServiceName); + + if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, + buf, + 0, + KEY_READ, + &hKey) != ERROR_SUCCESS) + { + GetError(); + return FALSE; + } + + /* set the display name */
ZeroMemory(&item, sizeof(LV_ITEM)); @@ -60,35 +79,51 @@ //item.iImage = 0; item.pszText = pServiceStatus[Index].lpDisplayName; item.iItem = ListView_GetItemCount(hListView); - item.lParam = 0; + //item.lParam = 0; item.iItem = ListView_InsertItem(hListView, &item);
/* set the description */ - - _stprintf(buf, _T("System\CurrentControlSet\Services\%s"), - pServiceStatus[Index].lpServiceName); - - if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, - buf, - 0, - KEY_READ, - &hKey) != ERROR_SUCCESS) + dwValueSize = 0; + ret = RegQueryValueEx(hKey, + _T("Description"), + NULL, + NULL, + NULL, + &dwValueSize); + if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND) { - GetError(); + RegCloseKey(hKey); return FALSE; } + + if (ret != ERROR_FILE_NOT_FOUND) + { + Description = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize); + if (Description == NULL) + { + RegCloseKey(hKey); + return FALSE; + } + if(RegQueryValueEx(hKey, + _T("Description"), + NULL, + NULL, + (LPBYTE)Description, + &dwValueSize)) + { + HeapFree(GetProcessHeap(), 0, Description); + RegCloseKey(hKey); + return FALSE; + }
- RegQueryValueEx(hKey, - _T("Description"), - NULL, - NULL, - (LPBYTE)Description, - &Size); + item.pszText = Description; + item.iSubItem = 1; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
- item.pszText = Description; - item.iSubItem = 1; - SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + HeapFree(GetProcessHeap(), 0, Description); + } +
/* set the status */ @@ -106,9 +141,88 @@ item.iSubItem = 2; SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); } - } - }
+ /* set the startup type */ + + dwValueSize = sizeof(DWORD); + if (RegQueryValueEx(hKey, + _T("Start"), + NULL, + NULL, + (LPBYTE)StartUp, + &dwValueSize)) + { + RegCloseKey(hKey); + return FALSE; + } + + if (StartUp == 0x02) + { + LoadString(hInstance, IDS_SERVICES_AUTO, szStatus, 128); + item.pszText = szStatus; + item.iSubItem = 2; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + } + else if (StartUp == 0x03) + { + LoadString(hInstance, IDS_SERVICES_MAN, szStatus, 128); + item.pszText = szStatus; + item.iSubItem = 2; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + } + else if (StartUp == 0x04) + { + LoadString(hInstance, IDS_SERVICES_DIS, szStatus, 128); + item.pszText = szStatus; + item.iSubItem = 2; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + } + + + + /* set Log On As */ + + dwValueSize = 0; + if (RegQueryValueEx(hKey, + _T("ObjectName"), + NULL, + NULL, + NULL, + &dwValueSize)) + { + RegCloseKey(hKey); + return FALSE; + } + + LogOnAs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize); + if (LogOnAs == NULL) + { + RegCloseKey(hKey); + return FALSE; + } + if(RegQueryValueEx(hKey, + _T("ObjectName"), + NULL, + NULL, + (LPBYTE)LogOnAs, + &dwValueSize)) + { + HeapFree(GetProcessHeap(), 0, LogOnAs); + RegCloseKey(hKey); + return FALSE; + } + + item.pszText = LogOnAs; + item.iSubItem = 4; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + + HeapFree(GetProcessHeap(), 0, LogOnAs); + + RegCloseKey(hKey); + + } + } + return TRUE; }
_____
Modified: trunk/reactos/subsys/system/servman/res/system.ico (Binary files differ) _____
Modified: trunk/reactos/subsys/system/servman/resource.h --- trunk/reactos/subsys/system/servman/resource.h 2006-01-07 01:06:48 UTC (rev 20635) +++ trunk/reactos/subsys/system/servman/resource.h 2006-01-07 01:14:38 UTC (rev 20636) @@ -43,7 +43,10 @@
#define IDS_SERVICES_STATUS_STOPPED 5001 #define IDS_SERVICES_YES 5002 #define IDS_SERVICES_UNKNOWN 5003 -#define IDS_SERVICES_NUM_SERVICES 5004 +#define IDS_SERVICES_AUTO 5004 +#define IDS_SERVICES_MAN 5005 +#define IDS_SERVICES_DIS 5006 +#define IDS_SERVICES_NUM_SERVICES 5010
#define IDB_START 50 #define IDI_SM_ICON 51