fix msvc warnings
[reactos.git] / reactos / subsys / system / servman / query.c
index 687aab3..523b223 100644 (file)
@@ -1,3 +1,12 @@
+/*\r
+ * PROJECT:     ReactOS Services\r
+ * LICENSE:     GPL - See COPYING in the top level directory\r
+ * FILE:        subsys/system/servman/query.c\r
+ * PURPOSE:     Query service information\r
+ * COPYRIGHT:   Copyright 2005 Ged Murphy <gedmurphy@gmail.com>\r
+ *               \r
+ */\r
+\r
 #include "servman.h"\r
 \r
 extern HINSTANCE hInstance;\r
@@ -18,11 +27,14 @@ VOID FreeMemory(VOID)
 BOOL\r
 RefreshServiceList(VOID)\r
 {\r
-    LV_ITEM item;\r
+    LVITEM item;\r
     TCHAR szNumServices[32];\r
     TCHAR szStatus[128];\r
     DWORD NumServices = 0;\r
     DWORD Index;\r
+    LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");\r
+\r
+    ListView_DeleteAllItems(hListView);\r
 \r
     NumServices = GetServiceList();\r
 \r
@@ -30,11 +42,11 @@ RefreshServiceList(VOID)
     {\r
         HICON hiconItem;     /* icon for list-view items */\r
         HIMAGELIST hSmall;   /* image list for other views */\r
-        TCHAR buf[40];\r
+        TCHAR buf[300];\r
 \r
         /* Create the icon image lists */\r
         hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),\r
-            GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);\r
+        GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR16, 1, 1);\r
 \r
         /* Add an icon to each image list */\r
         hiconItem = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SM_ICON), IMAGE_ICON, 16, 16, 0);\r
@@ -44,7 +56,7 @@ RefreshServiceList(VOID)
 \r
         /* set the number of services in the status bar */\r
         LoadString(hInstance, IDS_SERVICES_NUM_SERVICES, szNumServices, 32);\r
-        _stprintf(buf, szNumServices, NumServices);\r
+        _sntprintf(buf, 300, szNumServices, NumServices);\r
         SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);\r
 \r
 \r
@@ -58,7 +70,7 @@ RefreshServiceList(VOID)
             DWORD dwValueSize;\r
 \r
              /* open the registry key for the service */\r
-            _stprintf(buf, _T("System\\CurrentControlSet\\Services\\%s"),\r
+            _sntprintf(buf, 300, Path,\r
                       pServiceStatus[Index].lpServiceName);\r
 \r
             if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,\r
@@ -76,12 +88,11 @@ RefreshServiceList(VOID)
 \r
             ZeroMemory(&item, sizeof(LV_ITEM));\r
             item.mask = LVIF_TEXT;\r
-            //item.iImage = 0;\r
             item.pszText = pServiceStatus[Index].lpDisplayName;\r
             item.iItem = ListView_GetItemCount(hListView);\r
-            //item.lParam = 0;\r
             item.iItem = ListView_InsertItem(hListView, &item);\r
 \r
+            \r
 \r
             /* set the description */\r
             dwValueSize = 0;\r
@@ -123,7 +134,12 @@ RefreshServiceList(VOID)
 \r
                 HeapFree(GetProcessHeap(), 0, Description);\r
             }\r
-            \r
+            else\r
+            {\r
+                item.pszText = '\0';\r
+                item.iSubItem = 1;\r
+                SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+            }            \r
 \r
 \r
             /* set the status */\r
@@ -149,7 +165,7 @@ RefreshServiceList(VOID)
                                 _T("Start"),\r
                                 NULL,\r
                                 NULL,\r
-                                (LPBYTE)StartUp,\r
+                                (LPBYTE)&StartUp,\r
                                 &dwValueSize))\r
             {\r
                 RegCloseKey(hKey);\r
@@ -160,21 +176,21 @@ RefreshServiceList(VOID)
             {\r
                 LoadString(hInstance, IDS_SERVICES_AUTO, szStatus, 128);\r
                 item.pszText = szStatus;\r
-                item.iSubItem = 2;\r
+                item.iSubItem = 3;\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
+                item.iSubItem = 3;\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
+                item.iSubItem = 3;\r
                 SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
             }\r
 \r