From fa930470a4f689432b22c3f0fbe07528f36d992b Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 7 Jan 2006 01:14:38 +0000 Subject: [PATCH] pull service info out of the registry to populate the list view svn path=/trunk/; revision=20636 --- reactos/subsys/system/servman/En.rc | 3 + reactos/subsys/system/servman/query.c | 166 ++++++++++++++++--- reactos/subsys/system/servman/res/system.ico | Bin 3638 -> 3638 bytes reactos/subsys/system/servman/resource.h | 5 +- 4 files changed, 147 insertions(+), 27 deletions(-) diff --git a/reactos/subsys/system/servman/En.rc b/reactos/subsys/system/servman/En.rc index e5b16ac6caf..98c5f482022 100644 --- a/reactos/subsys/system/servman/En.rc +++ b/reactos/subsys/system/servman/En.rc @@ -82,6 +82,9 @@ BEGIN 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 diff --git a/reactos/subsys/system/servman/query.c b/reactos/subsys/system/servman/query.c index 96458353eb4..687aab3296d 100644 --- a/reactos/subsys/system/servman/query.c +++ b/reactos/subsys/system/servman/query.c @@ -47,25 +47,17 @@ RefreshServiceList(VOID) _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; - - /* set the display name */ - - ZeroMemory(&item, sizeof(LV_ITEM)); - item.mask = LVIF_TEXT; - //item.iImage = 0; - item.pszText = pServiceStatus[Index].lpDisplayName; - item.iItem = ListView_GetItemCount(hListView); - item.lParam = 0; - item.iItem = ListView_InsertItem(hListView, &item); - - - /* set the description */ + 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); @@ -79,16 +71,59 @@ RefreshServiceList(VOID) 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); + /* set the display name */ + + ZeroMemory(&item, sizeof(LV_ITEM)); + item.mask = LVIF_TEXT; + //item.iImage = 0; + item.pszText = pServiceStatus[Index].lpDisplayName; + item.iItem = ListView_GetItemCount(hListView); + //item.lParam = 0; + item.iItem = ListView_InsertItem(hListView, &item); + + + /* set the description */ + dwValueSize = 0; + ret = RegQueryValueEx(hKey, + _T("Description"), + NULL, + NULL, + NULL, + &dwValueSize); + if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND) + { + 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; + } + + item.pszText = Description; + item.iSubItem = 1; + SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item); + + HeapFree(GetProcessHeap(), 0, Description); + } + /* set the status */ @@ -106,8 +141,87 @@ RefreshServiceList(VOID) 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; } diff --git a/reactos/subsys/system/servman/res/system.ico b/reactos/subsys/system/servman/res/system.ico index cc3fb03ac2b8f4c3d44acb022b720dcd56da85bc..7e69845c23a603fa4e5b34c0556d62cea671d7a8 100644 GIT binary patch delta 858 zcmZ8fTWb?R82z?QX^LptdTF~P8gCV~t%6rXZSaCfYfClSy7d;Qm(&h|NWD;96P1Dt znsMCVN_^-A)+JOCA^Mp80rjoLr^P>zrSq1DLY&!6N$7c)Io~%P55xLfUbUzn zW|PVDUDLXGV5O_FFFk~NZ@8bzWX$Bnie6^N^x0lrpGkTMpQs8njo$%yw>}t8nPoef zN>$yEU}Gw@x6K_?`%H8D#Hkk(rWudls+`bIoP}%053y`u>6xqEh{xl=+|P$9u2o^zND0E*m7#n_m(N_Z>w^8y)*R|M$1leZdR|lgAi~egV~3m~#^YJYY8S zK-!iKnaG~aS8DI5Q5Ra#3@uPj~SXm#Q69_sHQ1{t9{GHSj<-pDnb<; zT^+Dv7{>@o8;IIyzWmmzkmeLL%oxKAN5xOA&OE7#mY*L;lh#uxMQ7k00B?tV2NZ@UrCO<%T)ZkCS!!A)1^upSOTnYpQq0 z&s{n{IXQXbpFb~?_vl09*}N>XL9E_)J^RahdY%I1L7+alcr92(;Er|Q@`Qj2rrkZB ze0u+Jh%}HqdRK)NC~R=9@_rb|0ERawAmG)pO-Y+ioUl%MCCI?7s~g!YZU&Y=u>b^K zOlDvZW8wG@VlR}<%CbnW1tHY*(!6HtlwhBoMrrI`!zL zq>R<#y<@Ing1~UXa2$ezwv?n L|Ax)$IoeqPNPQ4p diff --git a/reactos/subsys/system/servman/resource.h b/reactos/subsys/system/servman/resource.h index 72ae8e50c01..f2c2c4e23f0 100644 --- a/reactos/subsys/system/servman/resource.h +++ b/reactos/subsys/system/servman/resource.h @@ -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