pull service info out of the registry to populate the list view
authorGed Murphy <gedmurphy@reactos.org>
Sat, 7 Jan 2006 01:14:38 +0000 (01:14 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sat, 7 Jan 2006 01:14:38 +0000 (01:14 +0000)
svn path=/trunk/; revision=20636

reactos/subsys/system/servman/En.rc
reactos/subsys/system/servman/query.c
reactos/subsys/system/servman/res/system.ico
reactos/subsys/system/servman/resource.h

index e5b16ac..98c5f48 100644 (file)
@@ -82,6 +82,9 @@ BEGIN
   IDS_SERVICES_STATUS_STOPPED "Stopped"\r
   IDS_SERVICES_YES "Yes"\r
   IDS_SERVICES_UNKNOWN "Unknown"\r
   IDS_SERVICES_STATUS_STOPPED "Stopped"\r
   IDS_SERVICES_YES "Yes"\r
   IDS_SERVICES_UNKNOWN "Unknown"\r
+  IDS_SERVICES_AUTO "Automatic"\r
+  IDS_SERVICES_MAN "Manual"\r
+  IDS_SERVICES_DIS "Disabled"\r
 END\r
 \r
 STRINGTABLE DISCARDABLE\r
 END\r
 \r
 STRINGTABLE DISCARDABLE\r
index 9645835..687aab3 100644 (file)
@@ -47,11 +47,30 @@ RefreshServiceList(VOID)
         _stprintf(buf, szNumServices, NumServices);\r
         SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);\r
 \r
         _stprintf(buf, szNumServices, NumServices);\r
         SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);\r
 \r
+\r
         for (Index = 0; Index < NumServices; Index++)\r
         {\r
             HKEY hKey = NULL;\r
         for (Index = 0; Index < NumServices; Index++)\r
         {\r
             HKEY hKey = NULL;\r
-            TCHAR Description[5000];\r
-            DWORD Size = 5000;\r
+            LPTSTR Description = NULL;\r
+            LONG ret;\r
+            LPTSTR LogOnAs = NULL;\r
+            DWORD StartUp = 0;\r
+            DWORD dwValueSize;\r
+\r
+             /* open the registry key for the service */\r
+            _stprintf(buf, _T("System\\CurrentControlSet\\Services\\%s"),\r
+                      pServiceStatus[Index].lpServiceName);\r
+\r
+            if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,\r
+                             buf,\r
+                             0,\r
+                             KEY_READ,\r
+                             &hKey) != ERROR_SUCCESS)\r
+            {\r
+                GetError();\r
+                return FALSE;\r
+            }\r
+\r
 \r
             /* set the display name */\r
 \r
 \r
             /* set the display name */\r
 \r
@@ -60,35 +79,51 @@ RefreshServiceList(VOID)
             //item.iImage = 0;\r
             item.pszText = pServiceStatus[Index].lpDisplayName;\r
             item.iItem = ListView_GetItemCount(hListView);\r
             //item.iImage = 0;\r
             item.pszText = pServiceStatus[Index].lpDisplayName;\r
             item.iItem = ListView_GetItemCount(hListView);\r
-            item.lParam = 0;\r
+            //item.lParam = 0;\r
             item.iItem = ListView_InsertItem(hListView, &item);\r
 \r
 \r
             /* set the description */\r
             item.iItem = ListView_InsertItem(hListView, &item);\r
 \r
 \r
             /* set the description */\r
-\r
-            _stprintf(buf, _T("System\\CurrentControlSet\\Services\\%s"),\r
-                      pServiceStatus[Index].lpServiceName);\r
-\r
-            if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,\r
-                             buf,\r
-                             0,\r
-                             KEY_READ,\r
-                             &hKey) != ERROR_SUCCESS)\r
+            dwValueSize = 0;\r
+            ret = RegQueryValueEx(hKey,\r
+                                _T("Description"),\r
+                                NULL,\r
+                                NULL,\r
+                                NULL,\r
+                                &dwValueSize);\r
+            if (ret != ERROR_SUCCESS && ret != ERROR_FILE_NOT_FOUND)\r
             {\r
             {\r
-                GetError();\r
+                RegCloseKey(hKey);\r
                 return FALSE;\r
             }\r
                 return FALSE;\r
             }\r
+            \r
+            if (ret != ERROR_FILE_NOT_FOUND)\r
+            {\r
+                Description = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize);\r
+                if (Description == NULL)\r
+                {\r
+                    RegCloseKey(hKey);\r
+                    return FALSE;\r
+                }\r
+                if(RegQueryValueEx(hKey,\r
+                                   _T("Description"),\r
+                                   NULL,\r
+                                   NULL,\r
+                                   (LPBYTE)Description,\r
+                                   &dwValueSize))\r
+                {\r
+                    HeapFree(GetProcessHeap(), 0, Description);\r
+                    RegCloseKey(hKey);\r
+                    return FALSE;\r
+                }\r
 \r
 \r
-            RegQueryValueEx(hKey,\r
-                            _T("Description"),\r
-                            NULL,\r
-                            NULL,\r
-                            (LPBYTE)Description,\r
-                            &Size);\r
+                item.pszText = Description;\r
+                item.iSubItem = 1;\r
+                SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
 \r
 \r
-            item.pszText = Description;\r
-            item.iSubItem = 1;\r
-            SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+                HeapFree(GetProcessHeap(), 0, Description);\r
+            }\r
+            \r
 \r
 \r
             /* set the status */\r
 \r
 \r
             /* set the status */\r
@@ -106,8 +141,87 @@ RefreshServiceList(VOID)
                 item.iSubItem = 2;\r
                 SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
             }\r
                 item.iSubItem = 2;\r
                 SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
             }\r
-         }\r
-    }\r
+\r
+            /* set the startup type */\r
+\r
+            dwValueSize = sizeof(DWORD);\r
+            if (RegQueryValueEx(hKey,\r
+                                _T("Start"),\r
+                                NULL,\r
+                                NULL,\r
+                                (LPBYTE)StartUp,\r
+                                &dwValueSize))\r
+            {\r
+                RegCloseKey(hKey);\r
+                return FALSE;\r
+            }\r
+\r
+            if (StartUp == 0x02)\r
+            {\r
+                LoadString(hInstance, IDS_SERVICES_AUTO, szStatus, 128);\r
+                item.pszText = szStatus;\r
+                item.iSubItem = 2;\r
+                SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+            }\r
+            else if (StartUp == 0x03)\r
+            {\r
+                LoadString(hInstance, IDS_SERVICES_MAN, szStatus, 128);\r
+                item.pszText = szStatus;\r
+                item.iSubItem = 2;\r
+                SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+            }\r
+            else if (StartUp == 0x04)\r
+            {\r
+                LoadString(hInstance, IDS_SERVICES_DIS, szStatus, 128);\r
+                item.pszText = szStatus;\r
+                item.iSubItem = 2;\r
+                SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+            }\r
+\r
+\r
+\r
+            /* set Log On As */\r
+\r
+            dwValueSize = 0;\r
+            if (RegQueryValueEx(hKey,\r
+                                _T("ObjectName"),\r
+                                NULL,\r
+                                NULL,\r
+                                NULL,\r
+                                &dwValueSize))\r
+            {\r
+                RegCloseKey(hKey);\r
+                return FALSE;\r
+            }\r
+            \r
+            LogOnAs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwValueSize);\r
+            if (LogOnAs == NULL)\r
+            {\r
+                RegCloseKey(hKey);\r
+                return FALSE;\r
+            }\r
+            if(RegQueryValueEx(hKey,\r
+                               _T("ObjectName"),\r
+                               NULL,\r
+                               NULL,\r
+                               (LPBYTE)LogOnAs,\r
+                               &dwValueSize))\r
+            {\r
+                HeapFree(GetProcessHeap(), 0, LogOnAs);\r
+                RegCloseKey(hKey);\r
+                return FALSE;\r
+            }\r
+\r
+            item.pszText = LogOnAs;\r
+            item.iSubItem = 4;\r
+            SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+\r
+            HeapFree(GetProcessHeap(), 0, LogOnAs);\r
+\r
+            RegCloseKey(hKey);\r
+\r
+        }\r
+    } \r
 \r
     return TRUE;\r
 }\r
 \r
     return TRUE;\r
 }\r
index cc3fb03..7e69845 100644 (file)
Binary files a/reactos/subsys/system/servman/res/system.ico and b/reactos/subsys/system/servman/res/system.ico differ
index 72ae8e5..f2c2c4e 100644 (file)
 #define IDS_SERVICES_STATUS_STOPPED 5001\r
 #define IDS_SERVICES_YES 5002\r
 #define IDS_SERVICES_UNKNOWN 5003\r
 #define IDS_SERVICES_STATUS_STOPPED 5001\r
 #define IDS_SERVICES_YES 5002\r
 #define IDS_SERVICES_UNKNOWN 5003\r
-#define IDS_SERVICES_NUM_SERVICES 5004\r
+#define IDS_SERVICES_AUTO 5004\r
+#define IDS_SERVICES_MAN 5005\r
+#define IDS_SERVICES_DIS 5006\r
+#define IDS_SERVICES_NUM_SERVICES 5010\r
 \r
 #define IDB_START 50\r
 #define IDI_SM_ICON 51\r
 \r
 #define IDB_START 50\r
 #define IDI_SM_ICON 51\r