- Resource added for creating a service
authorGed Murphy <gedmurphy@reactos.org>
Fri, 20 Jan 2006 17:29:50 +0000 (17:29 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Fri, 20 Jan 2006 17:29:50 +0000 (17:29 +0000)
- Allow the prop sheet to control services
- Add exe path to prop sheet
- Only update the listview item itself when changing a service state

svn path=/trunk/; revision=20953

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

index 102f036..24f7275 100644 (file)
@@ -57,7 +57,7 @@ CAPTION "About Service Manager"
 FONT 8,"Tahoma",0,0\r
 STYLE 0x00C80080\r
 BEGIN\r
-  CONTROL "Service Manager v0.1\nCopyright (C) 2006\nby Ged Murphy (gedmurphy@gmail.com)",IDC_STATIC,"Static",WS_VISIBLE|0x0002000C,48,7,130,26\r
+  CONTROL "Service Manager v0.1\nCopyright (C) 2006\nby Ged Murphy (gedmurphy@gmail.com)",IDC_STATIC,"Static",0x1002000C,48,7,130,26\r
   CONTROL "Close",IDOK,"Button",0x50030001,75,162,44,15\r
   CONTROL "",IDI_SM_ICON,"Static",0x50000203,0,12,7,30\r
   CONTROL "",IDC_LICENSE_EDIT,"Edit",0x50210804,8,44,174,107,0x00000200\r
@@ -67,7 +67,6 @@ CAPTION "General"
 FONT 8,"MS Sans Serif",0,0\r
 STYLE 0x10CF0000\r
 BEGIN\r
-  CONTROL "Service name:",IDC_STATIC,"Static",0x50000000,4,11,53,11\r
   CONTROL "",IDC_DISP_NAME,"Static",0x50001000,70,29,176,12\r
   CONTROL "",IDC_DESCRIPTION,"Static",0x50201000,70,46,176,22\r
   CONTROL "",IDC_EXEPATH,"Static",0x50001000,6,86,238,12\r
@@ -76,6 +75,7 @@ BEGIN
   CONTROL "Stop",IDC_STOP,"Button",0x50010000,68,155,54,15\r
   CONTROL "Pause",IDC_PAUSE,"Button",0x50010000,130,155,54,15\r
   CONTROL "Resume",IDC_RESUME,"Button",0x50010000,192,155,54,15\r
+  CONTROL "Service name:",IDC_STATIC,"Static",0x50000000,4,11,53,11\r
   CONTROL "",IDC_START_PARAM,"Static",0x50001000,70,199,176,11\r
   CONTROL "Display name:",IDC_STATIC,"Static",0x50000000,4,29,53,11\r
   CONTROL "Description",IDC_STATIC,"Static",0x50000000,4,51,53,11\r
@@ -98,7 +98,28 @@ BEGIN
   CONTROL "This service depends on the following components",IDC_STATIC,"Static",0x50000000,8,57,236,9\r
   CONTROL "",IDC_DEPEND_SERVICE,"Static",0x50000000,8,38,236,13\r
 END\r
+IDD_DLG_CREATE DIALOGEX 6,6,225,209\r
+CAPTION "Create a service"\r
+FONT 8,"MS Sans Serif",0,0\r
+STYLE 0x10CF0000\r
+BEGIN\r
+  CONTROL "",IDC_CREATE_SERVNAME,"Edit",0x50010000,72,12,150,11,0x00000200\r
+  CONTROL "",IDC_CREATE_DISPNAME,"Edit",0x50010000,72,31,150,11,0x00000200\r
+  CONTROL "",IDC_CREATE_PATH,"Edit",0x50010000,8,62,214,13,0x00000200\r
+  CONTROL "",IDC_CREATE_DESC,"Edit",0x50010000,10,97,210,48,0x00000200\r
+  CONTROL "",IDC_CREATE_OPTIONS,"Edit",0x50010000,10,162,210,13,0x00000200\r
+  CONTROL "Service Name :",IDC_STATIC,"Static",0x50000202,12,12,54,9\r
+  CONTROL "Display Name :",IDC_STATIC,"Static",0x50000202,12,33,54,9\r
+  CONTROL "Path to executable :",IDC_STATIC,"Static",0x50000000,10,51,68,9\r
+  CONTROL "Description :",IDC_STATIC,"Static",0x50000000,12,86,44,9\r
+  CONTROL "OK",IDOK,"Button",0x50010000,126,192,44,13\r
+  CONTROL "Cancel",IDCANCEL,"Button",0x50010000,176,192,46,13\r
+  CONTROL "Additional options (click help for details)",IDC_STATIC,"Static",0x50000000,10,151,134,9\r
+  CONTROL "Help",ID_CREATE_HELP,"Button",0x50010000,6,192,44,13\r
+END\r
+\r
 IDB_BUTTONS BITMAP DISCARDABLE "res/toolbar.bmp"\r
+\r
 STRINGTABLE DISCARDABLE\r
 BEGIN\r
   IDS_FIRSTCOLUMN "Name"\r
index 89df57c..aea4515 100644 (file)
@@ -90,7 +90,7 @@ VOID GetDlgInfo(HWND hwndDlg)
     Service = (ENUM_SERVICE_STATUS_PROCESS *)item.lParam;\r
 \r
     /* open the registry key for the service */\r
-    _sntprintf(buf, 300, Path, Service->lpServiceName);\r
+    _sntprintf(buf, sizeof(buf) / sizeof(TCHAR), Path, Service->lpServiceName);\r
     RegOpenKeyEx(HKEY_LOCAL_MACHINE,\r
                  buf,\r
                  0,\r
@@ -99,23 +99,26 @@ VOID GetDlgInfo(HWND hwndDlg)
 \r
     /* set the service name */\r
     DlgInfo.lpServiceName = Service->lpServiceName;\r
-    SendDlgItemMessageW(hwndDlg, IDC_SERV_NAME, WM_SETTEXT, 0, (LPARAM)DlgInfo.lpServiceName);\r
+    SendDlgItemMessage(hwndDlg, IDC_SERV_NAME, WM_SETTEXT, 0, (\r
+        LPARAM)DlgInfo.lpServiceName);\r
 \r
 \r
     /* set the display name */\r
     DlgInfo.lpDisplayName = Service->lpDisplayName;\r
-    SendDlgItemMessageW(hwndDlg, IDC_DISP_NAME, WM_SETTEXT, 0, (LPARAM)DlgInfo.lpDisplayName);\r
+    SendDlgItemMessage(hwndDlg, IDC_DISP_NAME, WM_SETTEXT, 0,\r
+        (LPARAM)DlgInfo.lpDisplayName);\r
 \r
 \r
     /* set the description */\r
     if (GetDescription(hKey, &DlgInfo.lpDescription))\r
-        SendDlgItemMessageW(hwndDlg, IDC_DESCRIPTION, WM_SETTEXT, 0, (LPARAM)DlgInfo.lpDescription);\r
+        SendDlgItemMessage(hwndDlg, IDC_DESCRIPTION, WM_SETTEXT, 0,\r
+            (LPARAM)DlgInfo.lpDescription);\r
 \r
 \r
     /* FIXME: needs implementing. Use code base at bottom of query.c */\r
     /* set the executable path */\r
     if (GetExecutablePath(&DlgInfo.lpPathToExe))\r
-        SendDlgItemMessageW(hwndDlg, IDC_EXEPATH, WM_SETTEXT, 0, (LPARAM)DlgInfo.lpPathToExe);\r
+        SendDlgItemMessage(hwndDlg, IDC_EXEPATH, WM_SETTEXT, 0, (LPARAM)DlgInfo.lpPathToExe);\r
 \r
 \r
     /* set startup type */\r
@@ -163,17 +166,25 @@ GeneralPageProc(HWND hwndDlg,
     {\r
         case WM_INITDIALOG:\r
             GetDlgInfo(hwndDlg);\r
-\r
             break;\r
 \r
         case WM_COMMAND:\r
             switch(LOWORD(wParam))\r
             {\r
                 case IDC_START:\r
+                    SendMessage(hMainWnd, WM_COMMAND, ID_START, 0);\r
                     break;\r
 \r
                 case IDC_STOP:\r
+                    SendMessage(hMainWnd, WM_COMMAND, ID_STOP, 0);\r
+                    break;\r
+\r
+                case IDC_PAUSE:\r
+                    SendMessage(hMainWnd, WM_COMMAND, ID_PAUSE, 0);\r
+                    break;\r
 \r
+                case IDC_RESUME:\r
+                    SendMessage(hMainWnd, WM_COMMAND, ID_RESUME, 0);\r
                     break;\r
             }\r
             break;\r
index 875e556..fcd3ee4 100644 (file)
@@ -74,44 +74,64 @@ BOOL GetDescription(HKEY hKey, LPTSTR *retDescription)
 /* get vendor of service binary */\r
 BOOL GetExecutablePath(LPTSTR *ExePath)\r
 {\r
+    SC_HANDLE hSCManager = NULL;\r
+    SC_HANDLE hSc = NULL;\r
     LPQUERY_SERVICE_CONFIG pServiceConfig = NULL;\r
-    SC_HANDLE hService = NULL;\r
+    ENUM_SERVICE_STATUS_PROCESS *Service = NULL;\r
     LVITEM item;\r
-    WORD wCodePage, wLangID;\r
-    DWORD BytesNeeded = 0, dwHandle, dwLen;\r
+    DWORD BytesNeeded = 0;\r
     TCHAR FileName[MAX_PATH];\r
-    LPTSTR lpData;\r
-    LPTSTR lpBuffer;\r
-    TCHAR szStrFileInfo[80];\r
-    LPVOID pvData;\r
-    UINT BufLen;\r
 \r
 \r
-    if (!QueryServiceConfig(hService, pServiceConfig, 0, &BytesNeeded))\r
+    item.mask = LVIF_PARAM;\r
+    item.iItem = GetSelectedItem();\r
+    SendMessage(hListView, LVM_GETITEM, 0, (LPARAM)&item);\r
+\r
+    /* copy pointer to selected service */\r
+    Service = (ENUM_SERVICE_STATUS_PROCESS *)item.lParam;\r
+\r
+    /* open handle to the SCM */\r
+    hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);\r
+    if (hSCManager == NULL)\r
+    {\r
+        GetError(0);\r
+        return FALSE;\r
+    }\r
+\r
+    /* get a handle to the service requested for starting */\r
+    hSc = OpenService(hSCManager, Service->lpServiceName, SERVICE_QUERY_CONFIG);\r
+    if (hSc == NULL)\r
+    {\r
+        GetError(0);\r
+        goto cleanup;\r
+    }\r
+\r
+\r
+    if (!QueryServiceConfig(hSc, pServiceConfig, 0, &BytesNeeded))\r
     {\r
         if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)\r
         {\r
             pServiceConfig = (LPQUERY_SERVICE_CONFIG)\r
                 HeapAlloc(GetProcessHeap(), 0, BytesNeeded);\r
             if (pServiceConfig == NULL)\r
-                return FALSE;\r
+                goto cleanup;\r
 \r
-            if (!QueryServiceConfig(hService,\r
+            if (!QueryServiceConfig(hSc,\r
                                     pServiceConfig,\r
                                     BytesNeeded,\r
                                     &BytesNeeded))\r
             {\r
                 HeapFree(GetProcessHeap(), 0, pServiceConfig);\r
-                return FALSE;\r
+                goto cleanup;\r
             }\r
         }\r
         else /* exit on failure */\r
         {\r
-            return FALSE;\r
+            goto cleanup;\r
         }\r
     }\r
 \r
-    memset(&FileName, 0, MAX_PATH);\r
+    ZeroMemory(&FileName, MAX_PATH);\r
     if (_tcscspn(pServiceConfig->lpBinaryPathName, _T("\"")))\r
     {\r
         _tcsncpy(FileName, pServiceConfig->lpBinaryPathName,\r
@@ -122,46 +142,19 @@ BOOL GetExecutablePath(LPTSTR *ExePath)
         _tcscpy(FileName, pServiceConfig->lpBinaryPathName);\r
     }\r
 \r
-    HeapFree(GetProcessHeap(), 0, pServiceConfig);\r
-    pServiceConfig = NULL;\r
-\r
-    dwLen = GetFileVersionInfoSize(FileName, &dwHandle);\r
-    if (dwLen)\r
-    {\r
-        lpData = (TCHAR*) HeapAlloc(GetProcessHeap(), 0, dwLen);\r
-        if (lpData == NULL)\r
-            return FALSE;\r
-\r
-        if (!GetFileVersionInfo (FileName, dwHandle, dwLen, lpData)) {\r
-            HeapFree(GetProcessHeap(), 0, lpData);\r
-            return FALSE;\r
-        }\r
-\r
-        if (VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"), &pvData, (PUINT) &BufLen))\r
-        {\r
-            wCodePage = LOWORD(*(DWORD*) pvData);\r
-            wLangID = HIWORD(*(DWORD*) pvData);\r
-            wsprintf(szStrFileInfo, _T("StringFileInfo\\%04X%04X\\CompanyName"), wCodePage, wLangID);\r
-        }\r
-\r
-        if (VerQueryValue (lpData, szStrFileInfo, (LPVOID) &lpBuffer, (PUINT) &BufLen)) {\r
-            item.pszText = lpBuffer;\r
-            item.iSubItem = 2;\r
-            SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
-        }\r
-        HeapFree(GetProcessHeap(), 0, lpData);\r
-    }\r
-    /*else\r
-    {\r
-        LoadString(hInstance, IDS_SERVICES_UNKNOWN, szStatus, 128);\r
-        item.pszText = szStatus;\r
-        item.iSubItem = 2;\r
-        SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
-    }*/\r
+    *ExePath = FileName;\r
 \r
-    CloseServiceHandle(hService);\r
+    CloseServiceHandle(hSCManager);\r
+    CloseServiceHandle(hSc);\r
 \r
     return TRUE;\r
+\r
+cleanup:\r
+    if (hSCManager != NULL)\r
+        CloseServiceHandle(hSCManager);\r
+    if (hSc != NULL)\r
+        CloseServiceHandle(hSc);\r
+    return FALSE;\r
 }\r
 \r
 \r
@@ -172,7 +165,7 @@ RefreshServiceList(VOID)
 {\r
     LVITEM item;\r
     TCHAR szNumServices[32];\r
-    TCHAR szStatus[128];\r
+    TCHAR szStatus[64];\r
     DWORD NumServices = 0;\r
     DWORD Index;\r
     LPCTSTR Path = _T("System\\CurrentControlSet\\Services\\%s");\r
@@ -193,7 +186,8 @@ RefreshServiceList(VOID)
         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
+        hiconItem = LoadImage(hInstance, MAKEINTRESOURCE(IDI_SM_ICON),\r
+                              IMAGE_ICON, 16, 16, 0);\r
         ImageList_AddIcon(hSmall, hiconItem);\r
 \r
         /* assign the image to the list view */\r
@@ -249,9 +243,11 @@ RefreshServiceList(VOID)
 \r
             /* set the status */\r
 \r
-            if (pServiceStatus[Index].ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)\r
+            if (pServiceStatus[Index].ServiceStatusProcess.dwCurrentState\r
+                    == SERVICE_RUNNING)\r
             {\r
-                LoadString(hInstance, IDS_SERVICES_STARTED, szStatus, 128);\r
+                LoadString(hInstance, IDS_SERVICES_STARTED, szStatus,\r
+                    sizeof(szStatus) / sizeof(TCHAR));\r
                 item.pszText = szStatus;\r
                 item.iSubItem = 2;\r
                 SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
@@ -275,21 +271,24 @@ RefreshServiceList(VOID)
 \r
             if (StartUp == 0x02)\r
             {\r
-                LoadString(hInstance, IDS_SERVICES_AUTO, szStatus, 128);\r
+                LoadString(hInstance, IDS_SERVICES_AUTO, szStatus,\r
+                    sizeof(szStatus) / sizeof(TCHAR));\r
                 item.pszText = szStatus;\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
+                LoadString(hInstance, IDS_SERVICES_MAN, szStatus,\r
+                    sizeof(szStatus) / sizeof(TCHAR));\r
                 item.pszText = szStatus;\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
+                LoadString(hInstance, IDS_SERVICES_DIS, szStatus,\r
+                    sizeof(szStatus) / sizeof(TCHAR));\r
                 item.pszText = szStatus;\r
                 item.iSubItem = 3;\r
                 SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
@@ -342,7 +341,8 @@ RefreshServiceList(VOID)
         NumListedServ = ListView_GetItemCount(hListView);\r
 \r
         /* set the number of listed services in the status bar */\r
-        LoadString(hInstance, IDS_NUM_SERVICES, szNumServices, 32);\r
+        LoadString(hInstance, IDS_NUM_SERVICES, szNumServices,\r
+            sizeof(szNumServices) / sizeof(TCHAR));\r
         _sntprintf(buf, 300, szNumServices, NumListedServ);\r
         SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)buf);\r
     }\r
@@ -382,7 +382,8 @@ GetServiceList(VOID)
             if (GetLastError() == ERROR_MORE_DATA)\r
             {\r
                 /* reserve memory for service info array */\r
-                pServiceStatus = (ENUM_SERVICE_STATUS_PROCESS *) HeapAlloc(GetProcessHeap(), 0, BytesNeeded);\r
+                pServiceStatus = (ENUM_SERVICE_STATUS_PROCESS *)\r
+                        HeapAlloc(GetProcessHeap(), 0, BytesNeeded);\r
                 if (pServiceStatus == NULL)\r
                                return FALSE;\r
 \r
@@ -566,5 +567,53 @@ GetServiceList(VOID)
                     }\r
                     CloseServiceHandle(hService);\r
                 }\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+    HeapFree(GetProcessHeap(), 0, pServiceConfig);\r
+    pServiceConfig = NULL;\r
+\r
+    dwLen = GetFileVersionInfoSize(FileName, &dwHandle);\r
+    if (dwLen)\r
+    {\r
+        lpData = (TCHAR*) HeapAlloc(GetProcessHeap(), 0, dwLen);\r
+        if (lpData == NULL)\r
+            return FALSE;\r
+\r
+        if (!GetFileVersionInfo (FileName, dwHandle, dwLen, lpData)) {\r
+            HeapFree(GetProcessHeap(), 0, lpData);\r
+            return FALSE;\r
+        }\r
+\r
+        if (VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"),\r
+                          &pvData, (PUINT) &BufLen))\r
+        {\r
+            wCodePage = LOWORD(*(DWORD*) pvData);\r
+            wLangID = HIWORD(*(DWORD*) pvData);\r
+            wsprintf(szStrFileInfo, _T("StringFileInfo\\%04X%04X\\CompanyName"),\r
+                     wCodePage, wLangID);\r
+        }\r
+\r
+        if (VerQueryValue (lpData, szStrFileInfo, (LPVOID) &lpBuffer, (PUINT) &BufLen))\r
+        {\r
+            item.pszText = lpBuffer;\r
+            item.iSubItem = 2;\r
+            SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+        }\r
+        HeapFree(GetProcessHeap(), 0, lpData);\r
+    }\r
+    else\r
+    {\r
+        LoadString(hInstance, IDS_SERVICES_UNKNOWN, szStatus, 128);\r
+        item.pszText = szStatus;\r
+        item.iSubItem = 2;\r
+        SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+    }\r
+\r
+\r
 */\r
 \r
index fd55c64..ff5ec27 100644 (file)
 #define IDC_DEPEND_TREE2    20003\r
 #define IDC_DEPEND_SERVICE  20004\r
 \r
+\r
+/* create service dialog */\r
+#define IDD_DLG_CREATE 8000\r
+#define IDC_CREATE_SERVNAME 8001\r
+#define IDC_CREATE_DISPNAME 8002\r
+#define IDC_CREATE_PATH 8003\r
+#define IDC_CREATE_DESC 8004\r
+#define IDC_CREATE_OPTIONS 8005\r
+#define ID_CREATE_HELP 8006\r
index 55aa961..c36fd61 100644 (file)
@@ -332,6 +332,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                    {\r
                 case ID_PROP:\r
                     OpenPropSheet(hwnd);\r
+\r
                 break;\r
 \r
                 case ID_REFRESH:\r
@@ -342,29 +343,63 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 break;\r
 \r
                 case ID_START:\r
-                    DoStartService();\r
-                    RefreshServiceList();\r
+                    if ( DoStartService() )\r
+                    {\r
+                        LVITEM item;\r
+                        TCHAR szStatus[64];\r
+\r
+                        LoadString(hInstance, IDS_SERVICES_STARTED, szStatus,\r
+                            sizeof(szStatus) / sizeof(TCHAR));\r
+                        item.pszText = szStatus;\r
+                        item.iItem = GetSelectedItem();\r
+                        item.iSubItem = 2;\r
+                        SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+                    }\r
                            break;\r
 \r
                 case ID_STOP:\r
-                    Control(SERVICE_CONTROL_STOP);\r
-                    RefreshServiceList();\r
+                    if( Control(SERVICE_CONTROL_STOP) )\r
+                    {\r
+                        LVITEM item;\r
+\r
+                        item.pszText = '\0';\r
+                        item.iItem = GetSelectedItem();\r
+                        item.iSubItem = 2;\r
+                        SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+                    }\r
                 break;\r
 \r
                 case ID_PAUSE:\r
                     Control(SERVICE_CONTROL_PAUSE);\r
-                    RefreshServiceList();\r
                 break;\r
 \r
                 case ID_RESUME:\r
                     Control(SERVICE_CONTROL_CONTINUE );\r
-                    RefreshServiceList();\r
                 break;\r
 \r
                 case ID_RESTART:\r
-                    Control(SERVICE_CONTROL_STOP);\r
-                    DoStartService();\r
-                    RefreshServiceList();\r
+                    if( Control(SERVICE_CONTROL_STOP) )\r
+                    {\r
+                        LVITEM item;\r
+\r
+                        item.pszText = '\0';\r
+                        item.iItem = GetSelectedItem();\r
+                        item.iSubItem = 2;\r
+                        SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+\r
+                        if ( DoStartService() )\r
+                        {\r
+                            LVITEM item;\r
+                            TCHAR szStatus[64];\r
+\r
+                            LoadString(hInstance, IDS_SERVICES_STARTED, szStatus,\r
+                                sizeof(szStatus) / sizeof(TCHAR));\r
+                            item.pszText = szStatus;\r
+                            item.iItem = GetSelectedItem();\r
+                            item.iSubItem = 2;\r
+                            SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+                        }\r
+                    }\r
                 break;\r
 \r
                 case ID_NEW:\r
@@ -416,7 +451,6 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
 {\r
     WNDCLASSEX wc;\r
     MSG Msg;\r
-    BOOL bRet;\r
 \r
     hInstance = hThisInstance;\r
 \r
@@ -461,17 +495,11 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
     ShowWindow(hMainWnd, nCmdShow);\r
     UpdateWindow(hMainWnd);\r
 \r
-    while( (bRet = GetMessage( &Msg, NULL, 0, 0 )) != 0)\r
+    while( GetMessage( &Msg, NULL, 0, 0 ) )\r
     {\r
-        if (bRet == -1)\r
-        {\r
-            /* handle the error and possibly exit */\r
-        }\r
-        else\r
-        {\r
-            TranslateMessage(&Msg);\r
-            DispatchMessage(&Msg);\r
-        }\r
+        TranslateMessage(&Msg);\r
+        DispatchMessage(&Msg);\r
+\r
     }\r
     return (int)Msg.wParam;\r
 }\r