httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/support/win32 ApacheMonitor.c
Date Sun, 16 Jun 2002 19:02:58 GMT
wrowe       2002/06/16 12:02:58

  Modified:    support/win32 ApacheMonitor.c
  Log:
    Formating, whitespace, following {} rules, 80 char lines, etc.  The only
    significant variation from the general Apache rules is the construct:
  
    switch ()
    {
    case foo:
        case_fns();
    }
  
    indentation, since win32 switches are very common, but it's impossible
    to follow that rule and maintain legible 80 character line limits.  This
    is a common enough exception that I don't expect vocal objections.
  
  Revision  Changes    Path
  1.20      +944 -780  httpd-2.0/support/win32/ApacheMonitor.c
  
  Index: ApacheMonitor.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/win32/ApacheMonitor.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ApacheMonitor.c	14 Jun 2002 08:04:14 -0000	1.19
  +++ ApacheMonitor.c	16 Jun 2002 19:02:58 -0000	1.20
  @@ -97,7 +97,7 @@
   #define WM_TIMER_RESCAN        11
   #define SERVICE_APACHE_RESTART 128
   #define XBITMAP                16
  -#define YBITMAP                16 
  +#define YBITMAP                16
   #define MAX_LOADSTRING         100
   #define REFRESH_TIME           2000           /* service refresh time (ms) */
   #define RESCAN_TIME            20000          /* registry rescan time (ms) */
  @@ -120,8 +120,8 @@
   
   /* Global variables */
   HINSTANCE         g_hInstance = NULL;
  -CHAR              *g_szTitle;          /* The title bar text */
  -CHAR              *g_szWindowClass;    /* Window Class Name  */
  +CHAR             *g_szTitle;          /* The title bar text */
  +CHAR             *g_szWindowClass;    /* Window Class Name  */
   HICON             g_icoStop;
   HICON             g_icoRun;
   UINT              g_bUiTaskbarCreated;
  @@ -148,74 +148,84 @@
   HANDLE            g_hpipeStdError;
   LANGID            g_LangID;
   PROCESS_INFORMATION g_lpRedirectProc;
  -CRITICAL_SECTION    g_stcSection;
  +CRITICAL_SECTION  g_stcSection;
   LPSTR             g_szLocalHost;
   
   /* locale language support */
   static CHAR *g_lpMsg[IDS_MSG_LAST - IDS_MSG_FIRST + 1];
   
  +
   void am_ClearServicesSt()
   {
       int i;
  -    for (i = 0; i < MAX_APACHE_SERVICES; i++)
  +    for (i = 0; i < MAX_APACHE_SERVICES; i++) 
       {
  -        if (g_stServices[i].szServiceName)
  +        if (g_stServices[i].szServiceName) {
               free(g_stServices[i].szServiceName);
  -        if (g_stServices[i].szDisplayName)
  +        }
  +        if (g_stServices[i].szDisplayName) {
               free(g_stServices[i].szDisplayName);
  -        if (g_stServices[i].szDescription)
  +        }
  +        if (g_stServices[i].szDescription) {
               free(g_stServices[i].szDescription);
  -        if (g_stServices[i].szImagePath)
  +        }
  +        if (g_stServices[i].szImagePath) {
               free(g_stServices[i].szImagePath);
  -        if (g_stServices[i].szComputerName)
  +        }
  +        if (g_stServices[i].szComputerName) {
               free(g_stServices[i].szComputerName);
  +        }
   
       }
  -    ZeroMemory(g_stServices, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES);
  +    memset(g_stServices, 0, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES);
   
   }
   
  +
   void am_ClearComputersSt()
   {
       int i;
  -    for (i = 0; i < MAX_APACHE_COMPUTERS; i++)
  -    {
  +    for (i = 0; i < MAX_APACHE_COMPUTERS; i++) {
           if (g_stComputers[i].szComputerName) {
               free(g_stComputers[i].szComputerName);
               RegCloseKey(g_stComputers[i].hRegistry);
           }
       }
  -    ZeroMemory(g_stComputers, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS);
  +    memset(g_stComputers, 0, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS);
   
   }
   
  -BOOL am_IsComputerConnected( LPSTR szComputerName)
  +
  +BOOL am_IsComputerConnected(LPSTR szComputerName)
   {
       int i = 0;
       while (g_stComputers[i].szComputerName != NULL) {
  -        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0)
  +        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0) {
               return TRUE;
  +        }
           ++i;
       }
       return FALSE;
   }
   
  -void am_DisconnectComputer( LPSTR szComputerName)
  +
  +void am_DisconnectComputer(LPSTR szComputerName)
   {
       int i = 0, j;
       while (g_stComputers[i].szComputerName != NULL) {
  -        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0)
  +        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0) {
               break;
  +        }
           ++i;
       }
       if (g_stComputers[i].szComputerName != NULL) {
           free(g_stComputers[i].szComputerName);
           RegCloseKey(g_stComputers[i].hRegistry);
  -        for( j = i; j < MAX_APACHE_COMPUTERS - 1; j++) {
  -            g_stComputers[i].szComputerName = g_stComputers[i+1].szComputerName;
  +        for (j = i; j < MAX_APACHE_COMPUTERS - 1; j++) {
  +            g_stComputers[i].szComputerName= g_stComputers[i+1].szComputerName;
               g_stComputers[i].hRegistry = g_stComputers[i+1].hRegistry;
           }
  -        for( i = j; i < MAX_APACHE_COMPUTERS; i++) {
  +        for (i = j; i < MAX_APACHE_COMPUTERS; i++) {
               g_stComputers[i].szComputerName = NULL;
               g_stComputers[i].hRegistry = NULL;
           }
  @@ -223,29 +233,31 @@
   
   }
   
  +
   void ErrorMessage(LPCSTR szError, BOOL bFatal)
   {
  -    LPVOID lpMsgBuf  = NULL;
  -    if (szError)
  -        MessageBox(NULL, szError, g_lpMsg[IDS_MSG_ERROR-IDS_MSG_FIRST],
  -                    MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION));
  -    else
  -    {
  +    LPVOID lpMsgBuf = NULL;
  +    if (szError) {
  +        MessageBox(NULL, szError, g_lpMsg[IDS_MSG_ERROR - IDS_MSG_FIRST],
  +                   MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION));
  +    }
  +    else {
           FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
  -            FORMAT_MESSAGE_FROM_SYSTEM |
  -            FORMAT_MESSAGE_IGNORE_INSERTS,
  -            NULL,
  -            GetLastError(),
  -            g_LangID,
  -            (LPSTR) &lpMsgBuf, 0, NULL);
  -        MessageBox(NULL, (LPCSTR)lpMsgBuf, g_lpMsg[IDS_MSG_ERROR-IDS_MSG_FIRST],
  -                    MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION));
  +                      FORMAT_MESSAGE_FROM_SYSTEM |
  +                      FORMAT_MESSAGE_IGNORE_INSERTS,
  +                      NULL, GetLastError(), g_LangID,
  +                      (LPSTR) &lpMsgBuf, 0, NULL);
  +        MessageBox(NULL, (LPCSTR)lpMsgBuf, 
  +                   g_lpMsg[IDS_MSG_ERROR - IDS_MSG_FIRST],
  +                   MB_OK | (bFatal ? MB_ICONERROR : MB_ICONEXCLAMATION));
           LocalFree(lpMsgBuf);
       }
  -    if ( bFatal)
  +    if (bFatal) {
           PostQuitMessage(0);
  +    }
   }
   
  +
   BOOL am_ConnectComputer(LPSTR szComputerName)
   {
       int i = 0;
  @@ -253,35 +265,39 @@
       char szTmp[MAX_PATH];
   
       while (g_stComputers[i].szComputerName != NULL) {
  -        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0)
  +        if (strcmp(g_stComputers[i].szComputerName, szComputerName) == 0) {
               return FALSE;
  +        }
           ++i;
       }
  -    if (i > MAX_APACHE_COMPUTERS - 1)
  +    if (i > MAX_APACHE_COMPUTERS - 1) {
           return FALSE;
  -    if (RegConnectRegistry(szComputerName, HKEY_LOCAL_MACHINE, &hKeyRemote) != ERROR_SUCCESS)
  -    {
  -        sprintf(szTmp, g_lpMsg[IDS_MSG_ECONNECT-IDS_MSG_FIRST], szComputerName);
  +    }
  +    if (RegConnectRegistry(szComputerName, HKEY_LOCAL_MACHINE, &hKeyRemote) 
  +            != ERROR_SUCCESS) {
  +        sprintf(szTmp, g_lpMsg[IDS_MSG_ECONNECT - IDS_MSG_FIRST], 
  +                szComputerName);
           ErrorMessage(szTmp, FALSE);
           return FALSE;
       }
  -    else 
  -    {
  +    else {
           g_stComputers[i].szComputerName = strdup(szComputerName);
           g_stComputers[i].hRegistry = hKeyRemote;
           return TRUE;
       }
   } 
   
  +
   LPSTR GetStringRes(int id)
   {
  -  static CHAR buffer[MAX_PATH];
  +    static CHAR buffer[MAX_PATH];
   
  -  buffer[0] = 0;
  -  LoadString(GetModuleHandle (NULL), id, buffer, MAX_PATH);
  -  return buffer;
  +    buffer[0] = 0;
  +    LoadString(GetModuleHandle(NULL), id, buffer, MAX_PATH);
  +    return buffer;
   }
   
  +
   BOOL GetSystemOSVersion(LPDWORD dwVersion)
   {
       OSVERSIONINFO osvi;
  @@ -289,112 +305,133 @@
       Try calling GetVersionEx using the OSVERSIONINFOEX structure.
       If that fails, try using the OSVERSIONINFO structure.
       */
  -    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
  +    memset(&osvi, 0, sizeof(OSVERSIONINFO));
       osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  -    
  -    if (!GetVersionEx(&osvi))
  +
  +    if (!GetVersionEx(&osvi)) {
           return FALSE;
  -    
  +    }
  +
       switch (osvi.dwPlatformId)
       {
  -    case VER_PLATFORM_WIN32_NT:        
  -        if (osvi.dwMajorVersion <= 4)
  +    case VER_PLATFORM_WIN32_NT:
  +        if (osvi.dwMajorVersion <= 4) {
               *dwVersion = OS_VERSION_WINNT;
  -        else if (osvi.dwMajorVersion == 5)
  +        }
  +        else if (osvi.dwMajorVersion == 5) {
               *dwVersion = OS_VERSION_WIN2K;
  -        else
  +        }
  +        else {
               return FALSE;
  -        
  -        break;        
  +        }
  +        break;
  +
       case VER_PLATFORM_WIN32_WINDOWS:
  -            *dwVersion = OS_VERSION_WIN9X;        
  +        *dwVersion = OS_VERSION_WIN9X;
           break;
  -        
  +
       case VER_PLATFORM_WIN32s:
  -            *dwVersion = 0;
  -        return FALSE;
       default:
  +        *dwVersion = 0;
           return FALSE;
  -        break;
  -   }
  -   return TRUE; 
  +    }
  +    return TRUE; 
   }
   
  +
   static VOID ShowNotifyIcon(HWND hWnd, DWORD dwMessage)
   {
  -    
       NOTIFYICONDATA nid;
  -    int  i = 0, n = 0;
  +    int i = 0, n = 0;
   
  -    ZeroMemory(&nid,sizeof(nid));
  +    memset(&nid, 0, sizeof(nid));
       nid.cbSize = sizeof(NOTIFYICONDATA);
       nid.hWnd = hWnd;
       nid.uID = 0xFF;
       nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
       nid.uCallbackMessage = WM_TRAYMESSAGE;
  -    
  +
       while (g_stServices[i].szServiceName != NULL)
  -    {    
  -        if (g_stServices[i].dwPid != 0)
  +    {
  +        if (g_stServices[i].dwPid != 0) {
               ++n;
  +        }
           ++i;
       }
       if (dwMessage != NIM_DELETE)
       {
  -        if (n)
  +        if (n) {
               nid.hIcon = g_icoRun;
  -        else
  +        }
  +        else {
               nid.hIcon = g_icoStop;
  +        }
       }
  -    else
  +    else {
           nid.hIcon = NULL;
  -    if (n == i && n > 0)
  -        lstrcpy(nid.szTip, g_lpMsg[IDS_MSG_RUNNINGALL-IDS_MSG_FIRST]);
  -    else if (n)
  -        sprintf(nid.szTip, g_lpMsg[IDS_MSG_RUNNING-IDS_MSG_FIRST], n, i);
  -    else if (i)
  -        sprintf(nid.szTip, g_lpMsg[IDS_MSG_RUNNINGNONE-IDS_MSG_FIRST], i);
  -    else
  -        lstrcpy(nid.szTip, g_lpMsg[IDS_MSG_NOSERVICES-IDS_MSG_FIRST]);
  +    }
  +    if (n == i && n > 0) {
  +        lstrcpy(nid.szTip, g_lpMsg[IDS_MSG_RUNNINGALL - IDS_MSG_FIRST]);
  +    }
  +    else if (n) {
  +        sprintf(nid.szTip, g_lpMsg[IDS_MSG_RUNNING - IDS_MSG_FIRST], n, i);
  +    }
  +    else if (i) {
  +        sprintf(nid.szTip, g_lpMsg[IDS_MSG_RUNNINGNONE - IDS_MSG_FIRST], i);
  +    }
  +    else {
  +        lstrcpy(nid.szTip, g_lpMsg[IDS_MSG_NOSERVICES - IDS_MSG_FIRST]);
  +    }
       Shell_NotifyIcon(dwMessage, &nid);
   }
   
  -void appendMenuItem(HMENU hMenu, UINT uMenuId, LPSTR szName, BOOL fDefault, BOOL fEnabled)
  +
  +void appendMenuItem(HMENU hMenu, UINT uMenuId, LPSTR szName, 
  +                    BOOL fDefault, BOOL fEnabled)
   {
       MENUITEMINFO mii;
  -    
  -    ZeroMemory(&mii, sizeof(MENUITEMINFO));
  +
  +    memset(&mii, 0, sizeof(MENUITEMINFO));
       mii.cbSize = sizeof(MENUITEMINFO);
       mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
       if (lstrlen(szName))
       {
           mii.fType = MFT_STRING;
           mii.wID = uMenuId;
  -        if (fDefault)
  +        if (fDefault) {
               mii.fState = MFS_DEFAULT;
  -        if (!fEnabled)
  +        }
  +        if (!fEnabled) {
               mii.fState |= MFS_DISABLED;
  +        }
           mii.dwTypeData = szName;
       }
  -    else
  +    else {
           mii.fType = MFT_SEPARATOR;
  +    }
       InsertMenuItem(hMenu, uMenuId, FALSE, &mii);
   }
   
  -void appendServiceMenu(HMENU hMenu, UINT uMenuId, LPSTR szServiceName, BOOL fRunning)
  +
  +void appendServiceMenu(HMENU hMenu, UINT uMenuId, 
  +                       LPSTR szServiceName, BOOL fRunning)
   {
       MENUITEMINFO mii;
  -    HMENU        smh;    
  +    HMENU smh;
   
       smh = CreatePopupMenu();
   
  -    appendMenuItem(smh,  IDM_SM_START + uMenuId, g_lpMsg[IDS_MSG_SSTART-IDS_MSG_FIRST], FALSE, !fRunning);
  -    appendMenuItem(smh,  IDM_SM_STOP + uMenuId, g_lpMsg[IDS_MSG_SSTOP-IDS_MSG_FIRST], FALSE, fRunning);
  -    appendMenuItem(smh,  IDM_SM_RESTART + uMenuId, g_lpMsg[IDS_MSG_SRESTART-IDS_MSG_FIRST], FALSE, fRunning);
  +    appendMenuItem(smh, IDM_SM_START + uMenuId, 
  +                   g_lpMsg[IDS_MSG_SSTART - IDS_MSG_FIRST], FALSE, !fRunning);
  +    appendMenuItem(smh, IDM_SM_STOP + uMenuId, 
  +                   g_lpMsg[IDS_MSG_SSTOP - IDS_MSG_FIRST], FALSE, fRunning);
  +    appendMenuItem(smh, IDM_SM_RESTART + uMenuId, 
  +                   g_lpMsg[IDS_MSG_SRESTART - IDS_MSG_FIRST], FALSE, fRunning);
   
  -    ZeroMemory(&mii, sizeof(MENUITEMINFO));
  +    memset(&mii, 0, sizeof(MENUITEMINFO));
       mii.cbSize = sizeof(MENUITEMINFO);
  -    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU | MIIM_CHECKMARKS;
  +    mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_SUBMENU 
  +              | MIIM_CHECKMARKS;
       mii.fType = MFT_STRING;
       mii.wID = uMenuId;
       mii.hbmpChecked = g_hBmpStart;
  @@ -405,6 +442,7 @@
       InsertMenuItem(hMenu, IDM_SM_SERVICE + uMenuId, FALSE, &mii);
   }
   
  +
   void ShowTryPopupMenu(HWND hWnd)
   {
       /* create popup menu */
  @@ -413,14 +451,22 @@
   
       if (hMenu)
       {
  -        appendMenuItem(hMenu, IDM_RESTORE, g_lpMsg[IDS_MSG_MNUSHOW-IDS_MSG_FIRST], TRUE, TRUE);
  -        if (g_dwOSVersion >= OS_VERSION_WINNT)
  -            appendMenuItem(hMenu, IDC_SMANAGER, g_lpMsg[IDS_MSG_MNUSERVICES-IDS_MSG_FIRST], FALSE, TRUE);
  +        appendMenuItem(hMenu, IDM_RESTORE, 
  +                       g_lpMsg[IDS_MSG_MNUSHOW - IDS_MSG_FIRST], 
  +                       TRUE, TRUE);
  +        if (g_dwOSVersion >= OS_VERSION_WINNT) {
  +            appendMenuItem(hMenu, IDC_SMANAGER, 
  +                           g_lpMsg[IDS_MSG_MNUSERVICES - IDS_MSG_FIRST], 
  +                           FALSE, TRUE);
  +        }
           appendMenuItem(hMenu, 0, "", FALSE, TRUE);
  -        appendMenuItem(hMenu, IDM_EXIT,  g_lpMsg[IDS_MSG_MNUEXIT-IDS_MSG_FIRST], FALSE, TRUE);
  +        appendMenuItem(hMenu, IDM_EXIT, 
  +                       g_lpMsg[IDS_MSG_MNUEXIT - IDS_MSG_FIRST],
  +                       FALSE, TRUE);
   
  -        if (!SetForegroundWindow(hWnd))
  +        if (!SetForegroundWindow(hWnd)) {
               SetForegroundWindow(NULL);
  +        }
           GetCursorPos(&pt);
           TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, 
                          pt.x, pt.y, 0, hWnd, NULL);
  @@ -428,6 +474,7 @@
       }
   }
   
  +
   void ShowTryServicesMenu(HWND hWnd)
   {
       /* create services list popup menu and submenus */
  @@ -438,15 +485,16 @@
       if (hMenu)
       {
           while (g_stServices[i].szServiceName != NULL)
  -        {   
  +        {
               appendServiceMenu(hMenu, i, g_stServices[i].szDisplayName,
  -                              g_stServices[i].dwPid != 0);               
  +                              g_stServices[i].dwPid != 0);
               ++i;
           }
           if (i)
           {
  -            if (!SetForegroundWindow(hWnd))
  +            if (!SetForegroundWindow(hWnd)) {
                   SetForegroundWindow(NULL);
  +            }
               GetCursorPos(&pt);
               TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, 
                              pt.x, pt.y, 0, hWnd, NULL);
  @@ -455,12 +503,13 @@
       }
   }
   
  +
   BOOL CenterWindow(HWND hwndChild)
   {
  -   RECT    rChild, rWorkArea;
  -   int     wChild, hChild;
  -   int     xNew, yNew;
  -   BOOL    bResult;
  +   RECT rChild, rWorkArea;
  +   int wChild, hChild;
  +   int xNew, yNew;
  +   BOOL bResult;
   
      /* Get the Height and Width of the child window */
      GetWindowRect(hwndChild, &rChild);
  @@ -468,11 +517,8 @@
      hChild = rChild.bottom - rChild.top;
   
      /* Get the limits of the 'workarea' */
  -   bResult = SystemParametersInfo(
  -      SPI_GETWORKAREA,
  -      sizeof(RECT),
  -      &rWorkArea,
  -      0);
  +   bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT),
  +                                  &rWorkArea, 0);
      if (!bResult) {
         rWorkArea.left = rWorkArea.top = 0;
         rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
  @@ -480,11 +526,13 @@
      }
   
      /* Calculate new X and Y position*/
  -   xNew = (rWorkArea.right - wChild)/2;
  -   yNew = (rWorkArea.bottom - hChild)/2;
  -   return SetWindowPos (hwndChild, HWND_TOP, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
  +   xNew = (rWorkArea.right - wChild) / 2;
  +   yNew = (rWorkArea.bottom - hChild) / 2;
  +   return SetWindowPos(hwndChild, HWND_TOP, xNew, yNew, 0, 0, 
  +                       SWP_NOSIZE | SWP_SHOWWINDOW);
   }
   
  +
   static void addListBoxItem(HWND hDlg, LPSTR lpStr, HBITMAP hBmp) 
   { 
       int nItem; 
  @@ -493,14 +541,15 @@
       SendMessage(hDlg, LB_SETITEMDATA, nItem, (LPARAM)hBmp); 
   } 
   
  +
   static void addListBoxString(HWND hListBox, LPSTR lpStr)
   {
       static int nItems = 0;
  -    if (!g_bDlgServiceOn)
  +    if (!g_bDlgServiceOn) {
           return;
  -
  +    }
       ++nItems;
  -    if ( nItems > MAX_LOADSTRING)
  +    if (nItems > MAX_LOADSTRING) 
       {
           SendMessage(hListBox, LB_RESETCONTENT, 0, 0); 
           nItems = 1;
  @@ -509,11 +558,13 @@
                         ListBox_AddString(hListBox, lpStr));
   
   }
  +
  +
   static DWORD WINAPI ConsoleOutputThread(LPVOID lpThreadParameter)
   {
       static BYTE lpBuffer[MAX_PATH+1];
       int nPtr = 0;
  -    BYTE  ch;
  +    BYTE ch;
       DWORD dwReaded;
   
       while (ReadFile(g_hpipeOutRead, &ch, 1, &dwReaded, NULL) == TRUE) 
  @@ -524,16 +575,18 @@
               {
                   lpBuffer[nPtr] = '\0';
                   addListBoxString(g_hwndStdoutList, lpBuffer);
  -                nPtr  = 0;
  +                nPtr = 0;
               } 
               else if (ch == '\t' && nPtr < (MAX_PATH - 4)) 
               {
                   int i;
  -                for (i = 0; i < 4; ++i)
  +                for (i = 0; i < 4; ++i) {
                       lpBuffer[nPtr++] = ' ';
  +                }
               }
  -            else if (ch != '\r')
  +            else if (ch != '\r') {
                   lpBuffer[nPtr++] = ch;
  +            }
           }
       }
       CloseHandle(g_hpipeInWrite);
  @@ -556,32 +609,33 @@
   
   BOOL RunRedirectedConsole(LPSTR szCmdLine)
   {
  -    
  -    DWORD  dwThreadId;
  +    DWORD dwThreadId;
       HANDLE hProc;
       STARTUPINFO stInfo;
       BOOL bResult;
  -    ZeroMemory(&stInfo, sizeof(stInfo));
  +
  +    memset(&stInfo, 0, sizeof(stInfo));
       stInfo.cb = sizeof(stInfo);
       stInfo.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
       stInfo.wShowWindow = SW_HIDE;
  -    
  +
       hProc = GetCurrentProcess();
   
  -    if (!CreatePipe(&g_hpipeInRead, &g_hpipeInWrite, NULL, MAX_PATH))
  +    if (!CreatePipe(&g_hpipeInRead, &g_hpipeInWrite, NULL, MAX_PATH)) {
           ErrorMessage(NULL, TRUE);
  -    if (!CreatePipe(&g_hpipeOutRead, &g_hpipeOutWrite, NULL, MAX_PATH*8))
  +    }
  +    if (!CreatePipe(&g_hpipeOutRead, &g_hpipeOutWrite, NULL, MAX_PATH*8)) {
           ErrorMessage(NULL, TRUE);
  -        
  +    }
       DuplicateHandle(hProc, g_hpipeInRead, hProc, &g_hpipeInRead, 0, TRUE, 
                       DUPLICATE_CLOSE_SOURCE|DUPLICATE_SAME_ACCESS);
       DuplicateHandle(hProc, g_hpipeOutWrite, hProc, &g_hpipeOutWrite, 0, TRUE, 
                       DUPLICATE_CLOSE_SOURCE|DUPLICATE_SAME_ACCESS);
       DuplicateHandle(hProc, g_hpipeOutWrite, hProc, &g_hpipeStdError, 0, TRUE, 
                       DUPLICATE_SAME_ACCESS);
  -    if (!g_hpipeInRead && !g_hpipeOutWrite && !g_hpipeStdError)
  +    if (!g_hpipeInRead && !g_hpipeOutWrite && !g_hpipeStdError) {
           ErrorMessage(NULL, TRUE);
  -
  +    }
       stInfo.hStdInput  = g_hpipeInRead;
       stInfo.hStdOutput = g_hpipeOutWrite;
       stInfo.hStdError  = g_hpipeStdError;
  @@ -593,7 +647,7 @@
           TRUE,
           CREATE_SUSPENDED,
           NULL,
  -        NULL ,
  +        NULL,
           &stInfo,
           &g_lpRedirectProc);
   
  @@ -603,71 +657,74 @@
       CloseHandle(g_hpipeStdError);
   
       if (!bResult)
  -    {     
  +    {
           CloseHandle(g_hpipeInWrite);
           CloseHandle(g_hpipeOutRead);
           CloseHandle(g_hpipeStdError);
           return FALSE;
       }
   
  -    CloseHandle(CreateThread(NULL, 0, ConsoleOutputThread, 0, 0, &dwThreadId));
  +    CloseHandle(CreateThread(NULL, 0, ConsoleOutputThread, 
  +                             0, 0, &dwThreadId));
       ResumeThread(g_lpRedirectProc.hThread);
  -    CloseHandle(CreateThread(NULL, 0, ConsoleWaitingThread, 0, 0, &dwThreadId));
  +    CloseHandle(CreateThread(NULL, 0, ConsoleWaitingThread,
  +                             0, 0, &dwThreadId));
   
       return TRUE;
   }
   
  -BOOL RunAndForgetConsole(LPSTR szCmdLine,
  -                         BOOL  bRedirectConsole)
  +
  +BOOL RunAndForgetConsole(LPSTR szCmdLine, BOOL bRedirectConsole)
   {
  -        
       STARTUPINFO stInfo;
       PROCESS_INFORMATION prInfo;
       BOOL bResult;
  -    
  -    if (bRedirectConsole)
  +
  +    if (bRedirectConsole) {
           return RunRedirectedConsole(szCmdLine);
  +    }
   
  -    
  -    ZeroMemory(&stInfo, sizeof(stInfo));
  +    memset(&stInfo, 0, sizeof(stInfo));
       stInfo.cb = sizeof(stInfo);
       stInfo.dwFlags = STARTF_USESHOWWINDOW;
       stInfo.wShowWindow = SW_HIDE;
   
       bResult = CreateProcess(NULL,
  -        szCmdLine,
  -        NULL,
  -        NULL,
  -        TRUE,
  -        CREATE_NEW_CONSOLE,
  -        NULL,
  -        NULL ,
  -        &stInfo,
  -        &prInfo);
  +                            szCmdLine,
  +                            NULL,
  +                            NULL,
  +                            TRUE,
  +                            CREATE_NEW_CONSOLE,
  +                            NULL,
  +                            NULL,
  +                            &stInfo,
  +                            &prInfo);
   
  -    if (!bResult)
  -    {     
  +    if (!bResult) {
           return FALSE;
       }
  -    if (g_dwOSVersion == OS_VERSION_WIN9X) /* give some time to rescan the status */
  +    if (g_dwOSVersion == OS_VERSION_WIN9X) {
  +        /* give some time to rescan the status */
           Sleep(2000);
  +    }
       CloseHandle(prInfo.hThread);
       CloseHandle(prInfo.hProcess);
       return TRUE;
   }
   
  -BOOL ApacheManageService(LPCSTR szServiceName, LPCSTR szImagePath, LPSTR szComputerName, DWORD dwCommand)
  +
  +BOOL ApacheManageService(LPCSTR szServiceName, LPCSTR szImagePath, 
  +                         LPSTR szComputerName, DWORD dwCommand)
   {
  -    
  -    CHAR      szBuf[MAX_PATH];
  -    CHAR      szMsg[MAX_PATH];
  -    LPSTR     sPos;
  -    BOOL      retValue;
  -    BOOL      serviceFlag = TRUE;
  +    CHAR szBuf[MAX_PATH];
  +    CHAR szMsg[MAX_PATH];
  +    LPSTR sPos;
  +    BOOL retValue;
  +    BOOL serviceFlag = TRUE;
       SC_HANDLE schService;
  -    SC_HANDLE schSCManager;    
  +    SC_HANDLE schSCManager;
       SERVICE_STATUS schSStatus;
  -    int       ticks;
  +    int ticks;
   
       if (g_dwOSVersion == OS_VERSION_WIN9X)
       {
  @@ -680,22 +737,27 @@
               case SERVICE_CONTROL_STOP:
                   lstrcat(szBuf, " -k shutdown -n ");
                   break;
  +
               case SERVICE_CONTROL_CONTINUE:
  -                sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTART-IDS_MSG_FIRST], szServiceName);
  +                sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTART - IDS_MSG_FIRST], 
  +                        szServiceName);
                   addListBoxString(g_hwndStdoutList, szMsg);
                   lstrcat(szBuf, " -k start -n ");
                   serviceFlag = FALSE;
                   break;
  +
               case SERVICE_APACHE_RESTART:
                   lstrcat(szBuf, " -k restart -n ");
                   break;
  +
               default:
                   return FALSE;
               }
               lstrcat(szBuf, szServiceName);
           }
  -        else
  +        else {
               return FALSE;
  +        }
           g_bConsoleRun = TRUE;
           SetCursor(g_hCursorHourglass);
           if (!RunAndForgetConsole(szBuf, serviceFlag))
  @@ -707,7 +769,8 @@
           }
           else if (!serviceFlag)
           {
  -            sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTARTED-IDS_MSG_FIRST], szServiceName);
  +            sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTARTED - IDS_MSG_FIRST], 
  +                    szServiceName);
               addListBoxString(g_hwndStdoutList, szMsg);
               g_bConsoleRun = FALSE;
               SetCursor(g_hCursorArrow);
  @@ -716,15 +779,14 @@
       }
       else
       {
  -        schSCManager = OpenSCManager(
  -            szComputerName,
  -            NULL,
  -            SC_MANAGER_ALL_ACCESS
  -           );
  -        if (!schSCManager)
  +        schSCManager = OpenSCManager(szComputerName, NULL,
  +                                     SC_MANAGER_ALL_ACCESS);
  +        if (!schSCManager) {
               return FALSE;
  -        
  -        schService = OpenService(schSCManager, szServiceName, SERVICE_ALL_ACCESS);
  +        }
  +
  +        schService = OpenService(schSCManager, szServiceName, 
  +                                 SERVICE_ALL_ACCESS);
           if (schService != NULL)
           {
               retValue = FALSE;
  @@ -732,152 +794,172 @@
               SetCursor(g_hCursorHourglass);
               switch (dwCommand)
               {
  -                case SERVICE_CONTROL_STOP:
  -                    sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTOP-IDS_MSG_FIRST], szServiceName);
  -                    addListBoxString(g_hwndStdoutList, szMsg);
  -                    if (ControlService(schService, SERVICE_CONTROL_STOP, &schSStatus)) 
  -                    {
  -                        Sleep(1000);
  -                        while (QueryServiceStatus(schService, &schSStatus)) 
  -                        {
  -                            if (schSStatus.dwCurrentState == SERVICE_STOP_PENDING)
  -                                Sleep(1000);
  -                            else
  -                                break;
  -                        }
  -                    }
  -                    if (QueryServiceStatus(schService, &schSStatus))
  +            case SERVICE_CONTROL_STOP:
  +                sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTOP - IDS_MSG_FIRST], 
  +                        szServiceName);
  +                addListBoxString(g_hwndStdoutList, szMsg);
  +                if (ControlService(schService, SERVICE_CONTROL_STOP, 
  +                                   &schSStatus)) {
  +                    Sleep(1000);
  +                    while (QueryServiceStatus(schService, &schSStatus)) 
                       {
  -                        if (schSStatus.dwCurrentState == SERVICE_STOPPED)
  +                        if (schSStatus.dwCurrentState == SERVICE_STOP_PENDING)
                           {
  -                            retValue = TRUE;
  -                            sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTOPPED-IDS_MSG_FIRST], szServiceName);
  -                            addListBoxString(g_hwndStdoutList, szMsg);
  +                            Sleep(1000);
                           }
  -                    }
  -                break;                
  -                case SERVICE_CONTROL_CONTINUE:
  -                    sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTART-IDS_MSG_FIRST], szServiceName);
  -                    addListBoxString(g_hwndStdoutList, szMsg);
  -
  -                    if (StartService(schService, 0, NULL)) 
  -                    {
  -                        Sleep(1000);
  -                        while (QueryServiceStatus(schService, &schSStatus)) 
  -                        {
  -                            if (schSStatus.dwCurrentState == SERVICE_START_PENDING)
  -                                Sleep(1000);
  -                            else
  -                                break;
  +                        else {
  +                            break;
                           }
                       }
  -                    if (QueryServiceStatus(schService, &schSStatus))
  +                }
  +                if (QueryServiceStatus(schService, &schSStatus))
  +                {
  +                    if (schSStatus.dwCurrentState == SERVICE_STOPPED)
                       {
  -                        if (schSStatus.dwCurrentState == SERVICE_RUNNING)
  -                        {
  -                            retValue = TRUE;
  -                            sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTARTED-IDS_MSG_FIRST], szServiceName);
  -                            addListBoxString(g_hwndStdoutList, szMsg);
  -                        }
  +                        retValue = TRUE;
  +                        sprintf(szMsg, 
  +                                g_lpMsg[IDS_MSG_SRVSTOPPED - IDS_MSG_FIRST], 
  +                                szServiceName);
  +                        addListBoxString(g_hwndStdoutList, szMsg);
                       }
  -                break;                
  -                case SERVICE_APACHE_RESTART:
  -                    sprintf(szMsg, g_lpMsg[IDS_MSG_SRVRESTART-IDS_MSG_FIRST], szServiceName);
  -                    addListBoxString(g_hwndStdoutList, szMsg);
  -                    if (ControlService(schService, SERVICE_APACHE_RESTART, &schSStatus)) 
  +                }
  +                break;
  +
  +            case SERVICE_CONTROL_CONTINUE:
  +                sprintf(szMsg, g_lpMsg[IDS_MSG_SRVSTART - IDS_MSG_FIRST],
  +                        szServiceName);
  +                addListBoxString(g_hwndStdoutList, szMsg);
  +
  +                if (StartService(schService, 0, NULL)) 
  +                {
  +                    Sleep(1000);
  +                    while (QueryServiceStatus(schService, &schSStatus)) 
                       {
  -                        ticks = 60;
  -                        while (schSStatus.dwCurrentState == SERVICE_START_PENDING) 
  +                        if (schSStatus.dwCurrentState == SERVICE_START_PENDING)
                           {
                               Sleep(1000);
  -                            if (!QueryServiceStatus(schService, &schSStatus))
  -                            {
  -                                CloseServiceHandle(schService);
  -                                CloseServiceHandle(schSCManager);
  -                                g_bConsoleRun = FALSE;
  -                                SetCursor(g_hCursorArrow);
  -                                return FALSE;
  -                            }
  -                            if (!--ticks)
  -                                break;
  +                        }
  +                        else {
  +                            break;
                           }
                       }
  +                }
  +                if (QueryServiceStatus(schService, &schSStatus))
  +                {
                       if (schSStatus.dwCurrentState == SERVICE_RUNNING)
                       {
                           retValue = TRUE;
  -                        sprintf(szMsg, g_lpMsg[IDS_MSG_SRVRESTARTED-IDS_MSG_FIRST], szServiceName);
  +                        sprintf(szMsg, 
  +                                g_lpMsg[IDS_MSG_SRVSTARTED - IDS_MSG_FIRST],
  +                                szServiceName);
                           addListBoxString(g_hwndStdoutList, szMsg);
                       }
  -                break;                
  +                }
  +                break;
  +
  +            case SERVICE_APACHE_RESTART:
  +                sprintf(szMsg, g_lpMsg[IDS_MSG_SRVRESTART - IDS_MSG_FIRST],
  +                        szServiceName);
  +                addListBoxString(g_hwndStdoutList, szMsg);
  +                if (ControlService(schService, SERVICE_APACHE_RESTART,
  +                                   &schSStatus)) 
  +                {
  +                    ticks = 60;
  +                    while (schSStatus.dwCurrentState == SERVICE_START_PENDING)
  +                    {
  +                        Sleep(1000);
  +                        if (!QueryServiceStatus(schService, &schSStatus))
  +                        {
  +                            CloseServiceHandle(schService);
  +                            CloseServiceHandle(schSCManager);
  +                            g_bConsoleRun = FALSE;
  +                            SetCursor(g_hCursorArrow);
  +                            return FALSE;
  +                        }
  +                        if (!--ticks) {
  +                            break;
  +                        }
  +                    }
  +                }
  +                if (schSStatus.dwCurrentState == SERVICE_RUNNING)
  +                {
  +                    retValue = TRUE;
  +                    sprintf(szMsg, 
  +                            g_lpMsg[IDS_MSG_SRVRESTARTED - IDS_MSG_FIRST],
  +                            szServiceName);
  +                    addListBoxString(g_hwndStdoutList, szMsg);
  +                }
  +                break;
               }
               CloseServiceHandle(schService);
               CloseServiceHandle(schSCManager);
  -            if (!retValue)
  -                ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED-IDS_MSG_FIRST], FALSE);
  +            if (!retValue) {
  +                ErrorMessage(g_lpMsg[IDS_MSG_SRVFAILED - IDS_MSG_FIRST], 
  +                             FALSE);
  +            }
               g_bConsoleRun = FALSE;
               SetCursor(g_hCursorArrow);
               return retValue;
  -            
           }
  -        else
  +        else {
               g_bRescanServices = TRUE;
  -        
  +        }
           CloseServiceHandle(schSCManager);
           return FALSE;
       }
  -    
  +
       return FALSE;
   }
   
  -BOOL IsServiceRunning(LPCSTR szServiceName, LPCSTR szComputerName, LPDWORD lpdwPid)
  -{
   
  -    DWORD                   dwPid;
  -    HWND                    hWnd;
  -    SC_HANDLE               schService;
  -    SC_HANDLE               schSCManager;    
  -    SERVICE_STATUS          schSStatus;
  +BOOL IsServiceRunning(LPCSTR szServiceName, LPCSTR szComputerName, 
  +                      LPDWORD lpdwPid)
  +{
  +    DWORD dwPid;
  +    HWND hWnd;
  +    SC_HANDLE schService;
  +    SC_HANDLE schSCManager;
  +    SERVICE_STATUS schSStatus;
   
       if (g_dwOSVersion == OS_VERSION_WIN9X)
       {
           hWnd = FindWindow("ApacheWin95ServiceMonitor", szServiceName);
  -        if (hWnd && GetWindowThreadProcessId(hWnd, &dwPid))
  +        if (hWnd && GetWindowThreadProcessId(hWnd, &dwPid)) 
           {
               *lpdwPid = 1;
               return TRUE;
           }
  -        else
  +        else {
               return FALSE;
  +        }
       }
       else
       {
  -
           dwPid = 0;
  -        schSCManager = OpenSCManager(
  -                            szComputerName,
  -                            NULL,
  -                            SC_MANAGER_ALL_ACCESS
  -                           );
  -        if (!schSCManager)
  +        schSCManager = OpenSCManager(szComputerName, NULL,
  +                                     SC_MANAGER_ALL_ACCESS);
  +        if (!schSCManager) {
               return FALSE;
  +        }
   
  -        schService = OpenService(schSCManager, szServiceName, SERVICE_QUERY_STATUS);
  +        schService = OpenService(schSCManager, szServiceName, 
  +                                 SERVICE_QUERY_STATUS);
           if (schService != NULL)
           {
               if (QueryServiceStatus(schService, &schSStatus))
               {
  -                
                   dwPid = schSStatus.dwCurrentState;
  -                if (lpdwPid)
  +                if (lpdwPid) {
                       *lpdwPid = 1;
  +                }
               }
               CloseServiceHandle(schService);
               CloseServiceHandle(schSCManager);
               return dwPid == SERVICE_RUNNING ? TRUE : FALSE;
           }
  -        else
  +        else {
               g_bRescanServices = TRUE;
  -
  +        }
           CloseServiceHandle(schSCManager);
           return FALSE;
   
  @@ -886,47 +968,49 @@
       return FALSE;
   }
   
  +
   BOOL FindRunningServices(void)
   {
       int i = 0;
       DWORD dwPid;
       BOOL rv = FALSE;
       while (g_stServices[i].szServiceName != NULL)
  -    {    
  -        if (!IsServiceRunning(g_stServices[i].szServiceName, g_stServices[i].szComputerName, &dwPid))
  +    {
  +        if (!IsServiceRunning(g_stServices[i].szServiceName, 
  +                              g_stServices[i].szComputerName, &dwPid)) {
               dwPid = 0;
  -        if (g_stServices[i].dwPid != dwPid)
  +        }
  +        if (g_stServices[i].dwPid != dwPid) {
               rv = TRUE;
  +        }
           g_stServices[i].dwPid = dwPid;
           ++i;
  -    }                        
  +    }
       return rv;
   }
   
  +
   BOOL GetApacheServicesStatus()
   {
  -
  -    CHAR    szKey[MAX_PATH];
  -    CHAR    achKey[MAX_PATH];
  -    CHAR    szImagePath[MAX_PATH];
  -    CHAR    szBuf[MAX_PATH];
  -    CHAR    szTmp[MAX_PATH];
  -
  -    HKEY    hKey, hSubKey, hKeyRemote;
  -    DWORD   retCode, rv, dwKeyType;
  -    DWORD   dwBufLen = MAX_PATH;
  -    int     i, stPos = 0;
  -    int     computers = 0;
  +    CHAR szKey[MAX_PATH];
  +    CHAR achKey[MAX_PATH];
  +    CHAR szImagePath[MAX_PATH];
  +    CHAR szBuf[MAX_PATH];
  +    CHAR szTmp[MAX_PATH];
  +    HKEY hKey, hSubKey, hKeyRemote;
  +    DWORD retCode, rv, dwKeyType;
  +    DWORD dwBufLen = MAX_PATH;
  +    int i, stPos = 0;
  +    int computers = 0;
   
       g_bRescanServices = FALSE;
   
  -    
       am_ClearServicesSt();
       while (g_stComputers[computers].szComputerName != NULL) {
           hKeyRemote = g_stComputers[computers].hRegistry;
           retCode = RegOpenKeyEx(hKeyRemote,
  -                                "System\\CurrentControlSet\\Services\\",
  -                                0, KEY_READ, &hKey);
  +                               "System\\CurrentControlSet\\Services\\",
  +                               0, KEY_READ, &hKey);
           if (retCode != ERROR_SUCCESS)
           {
               ErrorMessage(NULL, FALSE);
  @@ -934,7 +1018,6 @@
           }
           for (i = 0, retCode = ERROR_SUCCESS; retCode == ERROR_SUCCESS; i++)
           {
  -
               retCode = RegEnumKey(hKey, i, achKey, MAX_PATH);
               if (retCode == ERROR_SUCCESS)
               {
  @@ -942,44 +1025,61 @@
                   lstrcat(szKey, achKey);
   
                   if (RegOpenKeyEx(hKeyRemote, szKey, 0, 
  -                    KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
  +                                 KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
                   {
                       dwBufLen = MAX_PATH;
                       rv = RegQueryValueEx(hSubKey, "ImagePath", NULL,
  -                                          &dwKeyType, szImagePath, &dwBufLen);
  +                                         &dwKeyType, szImagePath, &dwBufLen);
   
  -                    if (rv == ERROR_SUCCESS && (dwKeyType == REG_SZ  || dwKeyType == REG_EXPAND_SZ) && dwBufLen)
  +                    if (rv == ERROR_SUCCESS
  +                            && (dwKeyType == REG_SZ 
  +                             || dwKeyType == REG_EXPAND_SZ)
  +                            && dwBufLen)
                       {
                           lstrcpy(szBuf, szImagePath);
                           CharLower(szBuf);
                           /* the service name could be Apache*.exe */
  -                        if (strstr(szBuf, "\\apache") != NULL && strstr(szBuf, ".exe") &&
  -                        (strstr(szBuf, "--ntservice") != NULL || strstr(szBuf, "-k ") !=NULL))
  +                        if ((strstr(szBuf, "\\apache") != NULL)
  +                                && strstr(szBuf, ".exe") 
  +                                && (strstr(szBuf, "--ntservice") != NULL 
  +                                       || strstr(szBuf, "-k ") != NULL))
                           {
                               g_stServices[stPos].szServiceName = strdup(achKey);
  -                            g_stServices[stPos].szImagePath = strdup(szImagePath);
  -                            g_stServices[stPos].szComputerName = strdup(g_stComputers[computers].szComputerName);
  +                            g_stServices[stPos].szImagePath = 
  +                                                           strdup(szImagePath);
  +                            g_stServices[stPos].szComputerName = 
  +                               strdup(g_stComputers[computers].szComputerName);
                               dwBufLen = MAX_PATH;
                               if (RegQueryValueEx(hSubKey, "Description", NULL,
  -                                          &dwKeyType, szBuf, &dwBufLen) == ERROR_SUCCESS)
  -                                g_stServices[stPos].szDescription = strdup(szBuf);
  -
  +                                                &dwKeyType, szBuf, &dwBufLen) 
  +                                    == ERROR_SUCCESS) {
  +                                g_stServices[stPos].szDescription = 
  +                                                                 strdup(szBuf);
  +                            }
                               dwBufLen = MAX_PATH;
                               if (RegQueryValueEx(hSubKey, "DisplayName", NULL,
  -                                          &dwKeyType, szBuf, &dwBufLen) == ERROR_SUCCESS) {
  -                                if (strcmp(g_stComputers[computers].szComputerName, g_szLocalHost) != 0) { 
  -                                    strcpy(szTmp, g_stComputers[computers].szComputerName + 2);
  +                                                &dwKeyType, szBuf, &dwBufLen) 
  +                                    == ERROR_SUCCESS) 
  +                            {
  +                                if (strcmp(g_stComputers[computers]
  +                                        .szComputerName, g_szLocalHost) != 0) 
  +                                { 
  +                                    strcpy(szTmp, g_stComputers[computers]
  +                                                      .szComputerName + 2);
                                       strcat(szTmp, "@");
                                       strcat(szTmp, szBuf);
                                   }
  -                                else
  -                                    strcpy( szTmp, szBuf);
  -                                g_stServices[stPos].szDisplayName= strdup(szTmp);
  +                                else {
  +                                    strcpy(szTmp, szBuf);
  +                                }
  +                                g_stServices[stPos].szDisplayName 
  +                                                        = strdup(szTmp);
   
                               }
                               ++stPos;
  -                            if (stPos >= MAX_APACHE_SERVICES)
  +                            if (stPos >= MAX_APACHE_SERVICES) {
                                   retCode = !ERROR_SUCCESS;
  +                            }
                           }
                       }
                       RegCloseKey(hSubKey);
  @@ -993,365 +1093,400 @@
       return TRUE;
   }
   
  -LRESULT CALLBACK ConnectDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  +
  +LRESULT CALLBACK ConnectDlgProc(HWND hDlg, UINT message, 
  +                                WPARAM wParam, LPARAM lParam)
   {
       CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
       switch (message) 
       { 
  - 
  -        case WM_INITDIALOG: 
  -            ShowWindow(hDlg, SW_HIDE);
  -            g_hwndConnectDlg = hDlg;
  -            CenterWindow(hDlg);
  -            ShowWindow(hDlg, SW_SHOW);
  -            SetFocus(GetDlgItem(hDlg, IDC_COMPUTER));
  -            return TRUE;
  -        case WM_COMMAND: 
  -            switch (LOWORD(wParam)) 
  -            { 
  -                case IDOK: 
  -                    ZeroMemory(szCmp, MAX_COMPUTERNAME_LENGTH+4);
  -                    strcpy(szCmp, "\\\\");
  -                    SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_GETTEXT, 
  -                        (WPARAM) MAX_COMPUTERNAME_LENGTH, (LPARAM) szCmp+2); 
  -
  -                    strupr(szCmp);
  -                    if (strlen(szCmp) < 3) {
  -                        EndDialog(hDlg, TRUE); 
  -                        return TRUE;
  -                    }
  -                    am_ConnectComputer(szCmp);
  -                    SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);                        
  -                case IDCANCEL:
  -                    EndDialog(hDlg, TRUE); 
  -                    return TRUE; 
  -                case IDC_LBROWSE:
  -                    {
  -                        BROWSEINFO      bi;
  -                        ITEMIDLIST      *il;
  -                        LPMALLOC        pMalloc;
  -                        memset(&bi, 0, sizeof(BROWSEINFO));
  -                        SHGetSpecialFolderLocation(hDlg, CSIDL_NETWORK, &il);
  -
  -                        bi.lpszTitle      = "ApacheMonitor :\nSelect Network Computer!";
  -                        bi.pszDisplayName = szCmp;
  -                        bi.hwndOwner =      hDlg;
  -                        bi.ulFlags =        BIF_BROWSEFORCOMPUTER;
  -                        bi.lpfn =           NULL;
  -                        bi.lParam =         0;
  -                        bi.iImage =         0;
  -                        bi.pidlRoot =       il;
  -                        
  -                        if (SHBrowseForFolder(&bi) != NULL) {                     
  -                                SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_SETTEXT, 
  -                                    (WPARAM) NULL, (LPARAM) szCmp); 
  -                        }
  -                        if (SHGetMalloc(&pMalloc)) {
  -                            pMalloc->lpVtbl->Free(pMalloc, il);
  -                            pMalloc->lpVtbl->Release(pMalloc);
  -                        }
  -                    }
  -                    return TRUE;
  +    case WM_INITDIALOG: 
  +        ShowWindow(hDlg, SW_HIDE);
  +        g_hwndConnectDlg = hDlg;
  +        CenterWindow(hDlg);
  +        ShowWindow(hDlg, SW_SHOW);
  +        SetFocus(GetDlgItem(hDlg, IDC_COMPUTER));
  +        return TRUE;
  +
  +    case WM_COMMAND: 
  +        switch (LOWORD(wParam)) 
  +        { 
  +        case IDOK: 
  +            memset(szCmp, 0, MAX_COMPUTERNAME_LENGTH+4);
  +            strcpy(szCmp, "\\\\");
  +            SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), WM_GETTEXT, 
  +                        (WPARAM) MAX_COMPUTERNAME_LENGTH, 
  +                        (LPARAM) szCmp+2); 
  +
  +            strupr(szCmp);
  +            if (strlen(szCmp) < 3) {
  +                EndDialog(hDlg, TRUE); 
  +                return TRUE;
  +            }
  +            am_ConnectComputer(szCmp);
  +            SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);
  +
  +        case IDCANCEL:
  +            EndDialog(hDlg, TRUE); 
  +            return TRUE; 
  +
  +        case IDC_LBROWSE:
  +        {
  +            BROWSEINFO bi;
  +            ITEMIDLIST *il;
  +            LPMALLOC pMalloc;
  +            memset(&bi, 0, sizeof(BROWSEINFO));
  +            SHGetSpecialFolderLocation(hDlg, CSIDL_NETWORK, &il);
  +
  +            bi.lpszTitle      = "ApacheMonitor :\nSelect Network Computer!";
  +            bi.pszDisplayName = szCmp;
  +            bi.hwndOwner =      hDlg;
  +            bi.ulFlags =        BIF_BROWSEFORCOMPUTER;
  +            bi.lpfn =           NULL;
  +            bi.lParam =         0;
  +            bi.iImage =         0;
  +            bi.pidlRoot =       il;
  +
  +            if (SHBrowseForFolder(&bi) != NULL) {
  +                SendMessage(GetDlgItem(hDlg, IDC_COMPUTER), 
  +                            WM_SETTEXT, 
  +                            (WPARAM) NULL, (LPARAM) szCmp); 
  +            }
  +            if (SHGetMalloc(&pMalloc)) {
  +                pMalloc->lpVtbl->Free(pMalloc, il);
  +                pMalloc->lpVtbl->Release(pMalloc);
               }
  -        break;
  -        case WM_QUIT:
  -        case WM_CLOSE: 
  -            EndDialog(hDlg, TRUE);
               return TRUE;
  -        default:
  -            return FALSE;
  +        }
  +        }
  +        break;
  +
  +    case WM_QUIT:
  +    case WM_CLOSE: 
  +        EndDialog(hDlg, TRUE);
  +        return TRUE;
  +
  +    default:
  +        return FALSE;
       }
       return FALSE;
   
   }
   
  -LRESULT CALLBACK ServiceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  -{
   
  -    CHAR        szBuf[MAX_PATH]; 
  -    HWND        hListBox;
  -    static      HWND  hStatusBar; 
  -    TEXTMETRIC  tm; 
  -    int         i, y; 
  -    HDC         hdcMem; 
  -    RECT        rcBitmap; 
  -    UINT        nItem;
  +LRESULT CALLBACK ServiceDlgProc(HWND hDlg, UINT message, 
  +                                WPARAM wParam, LPARAM lParam)
  +{
  +    CHAR szBuf[MAX_PATH]; 
  +    HWND hListBox;
  +    static HWND hStatusBar; 
  +    TEXTMETRIC tm; 
  +    int i, y; 
  +    HDC hdcMem; 
  +    RECT rcBitmap; 
  +    UINT nItem;
       LPMEASUREITEMSTRUCT lpmis; 
  -    LPDRAWITEMSTRUCT    lpdis; 
  +    LPDRAWITEMSTRUCT lpdis; 
   
  -    ZeroMemory(szBuf, MAX_PATH);
  +    memset(szBuf, 0, MAX_PATH);
       switch (message) 
  -    { 
  - 
  -        case WM_INITDIALOG: 
  -            ShowWindow(hDlg, SW_HIDE);
  -            g_hwndServiceDlg = hDlg;
  -            SetWindowText(hDlg, g_szTitle);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SSTART), g_lpMsg[IDS_MSG_SSTART-IDS_MSG_FIRST]);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SSTOP), g_lpMsg[IDS_MSG_SSTOP-IDS_MSG_FIRST]);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SRESTART), g_lpMsg[IDS_MSG_SRESTART-IDS_MSG_FIRST]);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SMANAGER), g_lpMsg[IDS_MSG_SERVICES-IDS_MSG_FIRST]);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SCONNECT), g_lpMsg[IDS_MSG_CONNECT-IDS_MSG_FIRST]);
  -            SetWindowText(GetDlgItem(hDlg, IDC_SEXIT), g_lpMsg[IDS_MSG_MNUEXIT-IDS_MSG_FIRST]);
  -            if (g_dwOSVersion < OS_VERSION_WINNT)
  -            {
  -                ShowWindow(GetDlgItem(hDlg, IDC_SMANAGER), SW_HIDE);
  -                ShowWindow(GetDlgItem(hDlg, IDC_SCONNECT), SW_HIDE);
  -                ShowWindow(GetDlgItem(hDlg, IDC_SDISCONN), SW_HIDE);
  -            }
  -            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -            g_hwndStdoutList = GetDlgItem(hDlg, IDL_STDOUT);
  -            hStatusBar = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
  -                                          | WS_CHILD | WS_VISIBLE,
  -                                            "", hDlg, IDC_STATBAR);            
  -            if (GetApacheServicesStatus())
  -            {
  -                i = 0;
  -                while (g_stServices[i].szServiceName != NULL)
  -                {    
  -                    addListBoxItem(hListBox, g_stServices[i].szDisplayName,
  -                        g_stServices[i].dwPid == 0 ? g_hBmpStop : g_hBmpStart);
  -                    ++i;
  -                }
  -            }
  -            CenterWindow(hDlg);
  -            ShowWindow(hDlg, SW_SHOW);
  -            SetFocus(hListBox); 
  -            SendMessage(hListBox, LB_SETCURSEL, 0, 0); 
  -            return TRUE;
  -        break;
  -        case WM_MANAGEMESSAGE:
  -            ApacheManageService(g_stServices[LOWORD(wParam)].szServiceName,
  -                        g_stServices[LOWORD(wParam)].szImagePath,
  -                        g_stServices[LOWORD(wParam)].szComputerName,
  -                        LOWORD(lParam));
  -    
  -            return TRUE;
  -        break;
  -        case WM_UPDATEMESSAGE:
  -            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -            SendMessage(hListBox, LB_RESETCONTENT, 0, 0); 
  -            SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)"");
  -            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -            Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  +    {
  +    case WM_INITDIALOG: 
  +        ShowWindow(hDlg, SW_HIDE);
  +        g_hwndServiceDlg = hDlg;
  +        SetWindowText(hDlg, g_szTitle);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SSTART), 
  +                      g_lpMsg[IDS_MSG_SSTART - IDS_MSG_FIRST]);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SSTOP), 
  +                      g_lpMsg[IDS_MSG_SSTOP - IDS_MSG_FIRST]);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SRESTART), 
  +                      g_lpMsg[IDS_MSG_SRESTART - IDS_MSG_FIRST]);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SMANAGER), 
  +                      g_lpMsg[IDS_MSG_SERVICES - IDS_MSG_FIRST]);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SCONNECT), 
  +                      g_lpMsg[IDS_MSG_CONNECT - IDS_MSG_FIRST]);
  +        SetWindowText(GetDlgItem(hDlg, IDC_SEXIT), 
  +                      g_lpMsg[IDS_MSG_MNUEXIT - IDS_MSG_FIRST]);
  +        if (g_dwOSVersion < OS_VERSION_WINNT)
  +        {
  +            ShowWindow(GetDlgItem(hDlg, IDC_SMANAGER), SW_HIDE);
  +            ShowWindow(GetDlgItem(hDlg, IDC_SCONNECT), SW_HIDE);
  +            ShowWindow(GetDlgItem(hDlg, IDC_SDISCONN), SW_HIDE);
  +        }
  +        hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +        g_hwndStdoutList = GetDlgItem(hDlg, IDL_STDOUT);
  +        hStatusBar = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
  +                                      | WS_CHILD | WS_VISIBLE,
  +                                        "", hDlg, IDC_STATBAR);
  +        if (GetApacheServicesStatus())
  +        {
               i = 0;
               while (g_stServices[i].szServiceName != NULL)
  -            {    
  -                addListBoxItem(hListBox, g_stServices[i].szDisplayName, 
  -                    g_stServices[i].dwPid == 0 ? g_hBmpStop : g_hBmpStart);
  +            {
  +                addListBoxItem(hListBox, g_stServices[i].szDisplayName,
  +                               g_stServices[i].dwPid == 0 ? g_hBmpStop 
  +                                                          : g_hBmpStart);
                   ++i;
               }
  -            SendMessage(hListBox, LB_SETCURSEL, 0, 0); 
  -            /* Dirty hack to bring the window to the foreground */
  -            SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0,
  -                                    SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  -            SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
  -                                    SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  -            SetFocus(hListBox); 
  -            return TRUE;
  +        }
  +        CenterWindow(hDlg);
  +        ShowWindow(hDlg, SW_SHOW);
  +        SetFocus(hListBox); 
  +        SendMessage(hListBox, LB_SETCURSEL, 0, 0); 
  +        return TRUE;
           break;
  -        case WM_MEASUREITEM: 
  - 
  -            lpmis = (LPMEASUREITEMSTRUCT) lParam; 
  -            lpmis->itemHeight = YBITMAP; 
  -            return TRUE; 
  -        case WM_SETCURSOR:
  -            if (g_bConsoleRun)
  -                SetCursor(g_hCursorHourglass);
  -            else
  -                SetCursor(g_hCursorArrow);
  -            return TRUE;
  -        case WM_DRAWITEM: 
  -            lpdis = (LPDRAWITEMSTRUCT) lParam; 
  -            if (lpdis->itemID == -1) 
  -            { 
  -                break; 
  -            } 
  -            switch (lpdis->itemAction) 
  -            { 
  -                case ODA_SELECT: 
  -                case ODA_DRAWENTIRE: 
  -                    g_hBmpPicture = (HBITMAP)SendMessage(lpdis->hwndItem, 
  -                        LB_GETITEMDATA, lpdis->itemID, (LPARAM) 0); 
  -                        
  -                    hdcMem = CreateCompatibleDC(lpdis->hDC); 
  -                    g_hBmpOld = SelectObject(hdcMem, g_hBmpPicture); 
  - 
  -                    BitBlt(lpdis->hDC, 
  -                        lpdis->rcItem.left, lpdis->rcItem.top, 
  -                        lpdis->rcItem.right - lpdis->rcItem.left, 
  -                        lpdis->rcItem.bottom - lpdis->rcItem.top, 
  -                        hdcMem, 0, 0, SRCCOPY); 
  -                    SendMessage(lpdis->hwndItem, LB_GETTEXT, 
  +
  +    case WM_MANAGEMESSAGE:
  +        ApacheManageService(g_stServices[LOWORD(wParam)].szServiceName,
  +                    g_stServices[LOWORD(wParam)].szImagePath,
  +                    g_stServices[LOWORD(wParam)].szComputerName,
  +                    LOWORD(lParam));
  +
  +        return TRUE;
  +        break;
  +
  +    case WM_UPDATEMESSAGE:
  +        hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +        SendMessage(hListBox, LB_RESETCONTENT, 0, 0); 
  +        SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)"");
  +        Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  +        Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  +        i = 0;
  +        while (g_stServices[i].szServiceName != NULL)
  +        {
  +            addListBoxItem(hListBox, g_stServices[i].szDisplayName, 
  +                g_stServices[i].dwPid == 0 ? g_hBmpStop : g_hBmpStart);
  +            ++i;
  +        }
  +        SendMessage(hListBox, LB_SETCURSEL, 0, 0); 
  +        /* Dirty hack to bring the window to the foreground */
  +        SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0,
  +                                SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  +        SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
  +                                SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  +        SetFocus(hListBox); 
  +        return TRUE;
  +        break;
  +
  +    case WM_MEASUREITEM: 
  +        lpmis = (LPMEASUREITEMSTRUCT) lParam; 
  +        lpmis->itemHeight = YBITMAP; 
  +        return TRUE; 
  +
  +    case WM_SETCURSOR:
  +        if (g_bConsoleRun) {
  +            SetCursor(g_hCursorHourglass);
  +        }
  +        else {
  +            SetCursor(g_hCursorArrow);
  +        }
  +        return TRUE;
  +
  +    case WM_DRAWITEM: 
  +        lpdis = (LPDRAWITEMSTRUCT) lParam; 
  +        if (lpdis->itemID == -1) { 
  +            break; 
  +        } 
  +        switch (lpdis->itemAction) 
  +        { 
  +        case ODA_SELECT: 
  +        case ODA_DRAWENTIRE: 
  +            g_hBmpPicture = (HBITMAP)SendMessage(lpdis->hwndItem, 
  +                                                 LB_GETITEMDATA,
  +                                                 lpdis->itemID, (LPARAM) 0);
  +
  +            hdcMem = CreateCompatibleDC(lpdis->hDC); 
  +            g_hBmpOld = SelectObject(hdcMem, g_hBmpPicture); 
  +
  +            BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
  +                   lpdis->rcItem.right - lpdis->rcItem.left,
  +                   lpdis->rcItem.bottom - lpdis->rcItem.top,
  +                   hdcMem, 0, 0, SRCCOPY);
  +            SendMessage(lpdis->hwndItem, LB_GETTEXT, 
                           lpdis->itemID, (LPARAM) szBuf); 
  - 
  -                    GetTextMetrics(lpdis->hDC, &tm);  
  -                    y = (lpdis->rcItem.bottom + lpdis->rcItem.top - 
  -                        tm.tmHeight) / 2; 
  -  
  -                    SelectObject(hdcMem, g_hBmpOld); 
  -                    DeleteDC(hdcMem); 
  - 
  -                    rcBitmap.left = lpdis->rcItem.left + XBITMAP + 2; 
  -                    rcBitmap.top = lpdis->rcItem.top; 
  -                    rcBitmap.right = lpdis->rcItem.right; 
  -                    rcBitmap.bottom = lpdis->rcItem.top + YBITMAP; 
  -
  -                    if (lpdis->itemState & ODS_SELECTED) 
  -                    { 
  -                        if (g_hBmpPicture == g_hBmpStop)
  -                        {
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), TRUE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -                        }
  -                        else if (g_hBmpPicture == g_hBmpStart) 
  -                        {
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), TRUE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE);
  -                        }
  -                        else {
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -                        }
  -                        if (strcmp(g_stServices[lpdis->itemID].szComputerName, g_szLocalHost) == 0)
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  -                        else
  -                            Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), TRUE);
  -
  -                        if (g_stServices[lpdis->itemID].szDescription)
  -                            SendMessage(hStatusBar, SB_SETTEXT, 0, 
  -                                        (LPARAM)g_stServices[lpdis->itemID].szDescription);
  -                        else
  -                            SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)"");
  -                        
  -                        SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 
  -                        SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 
  -                        FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_HIGHLIGHTTEXT)); 
  -                    } 
  -                    else
  -                    {
  -                       SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT)); 
  -                       SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW)); 
  -                       FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_WINDOW+1)); 
  -                    }
  -                    TextOut(lpdis->hDC, 
  -                        XBITMAP + 6, 
  -                        y, 
  -                        szBuf, 
  -                        strlen(szBuf)); 
  -                    break; 
  - 
  -                case ODA_FOCUS: 
  -                    break; 
  -            } 
  -            return TRUE;  
  -        case WM_COMMAND: 
  -            switch (LOWORD(wParam)) 
  -            { 
  -                case IDL_SERVICES:
  -                    switch (HIWORD(wParam))
  -                    {
  -                        case LBN_DBLCLK:
  -                            /* if started then stop, if stopped then start the service */
  -                            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -                            nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  -                            if (nItem != LB_ERR)
  -                            {
  -                                g_hBmpPicture = (HBITMAP)SendMessage(hListBox, LB_GETITEMDATA,
  -                                                               nItem, (LPARAM) 0); 
  -                                if (g_hBmpPicture == g_hBmpStop)
  -                                {
  -                                    SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, SERVICE_CONTROL_CONTINUE);                                    
  -                                }
  -                                else
  -                                    SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, SERVICE_CONTROL_STOP);                                    
   
  -                            }
  -                            return TRUE;
  -                        break;
  -                     }
  -                break;
  -                case IDOK: 
  -                    EndDialog(hDlg, TRUE); 
  -                    return TRUE; 
  -                case IDC_SSTART: 
  -                    Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  -                    hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -                    nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  -                    if (nItem != LB_ERR)
  -                    {
  -                        SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, SERVICE_CONTROL_CONTINUE);                                    
  -                    }
  +            GetTextMetrics(lpdis->hDC, &tm);
  +            y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
  +
  +            SelectObject(hdcMem, g_hBmpOld); 
  +            DeleteDC(hdcMem); 
  +
  +            rcBitmap.left = lpdis->rcItem.left + XBITMAP + 2; 
  +            rcBitmap.top = lpdis->rcItem.top; 
  +            rcBitmap.right = lpdis->rcItem.right; 
  +            rcBitmap.bottom = lpdis->rcItem.top + YBITMAP; 
  +
  +            if (lpdis->itemState & ODS_SELECTED) 
  +            { 
  +                if (g_hBmpPicture == g_hBmpStop)
  +                {
                       Button_Enable(GetDlgItem(hDlg, IDC_SSTART), TRUE);
  -                    return TRUE;
  -                case IDC_SSTOP: 
                       Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  -                    hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -                    nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  -                    if (nItem != LB_ERR)
  -                    {
  -                        SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, SERVICE_CONTROL_STOP);                                    
  -                    }
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  +                }
  +                else if (g_hBmpPicture == g_hBmpStart) 
  +                {
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
                       Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), TRUE);
  -                    return TRUE;
  -                case IDC_SRESTART: 
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE);
  +                }
  +                else {
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
                       Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  -                    hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -                    nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  -                    if (nItem != LB_ERR)
  -                    {
  -                        SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, SERVICE_APACHE_RESTART);                                    
  +                }
  +                if (strcmp(g_stServices[lpdis->itemID].szComputerName, 
  +                           g_szLocalHost) == 0) {
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), FALSE);
  +                }
  +                else {
  +                    Button_Enable(GetDlgItem(hDlg, IDC_SDISCONN), TRUE);
  +                }
  +
  +                if (g_stServices[lpdis->itemID].szDescription) {
  +                    SendMessage(hStatusBar, SB_SETTEXT, 0, 
  +                            (LPARAM)g_stServices[lpdis->itemID].szDescription);
  +                }
  +                else {
  +                    SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)"");
  +                }
  +                SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 
  +                SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 
  +                FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_HIGHLIGHTTEXT));
  +            } 
  +            else
  +            {
  +               SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT)); 
  +               SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW)); 
  +               FillRect(lpdis->hDC, &rcBitmap, (HBRUSH)(COLOR_WINDOW+1)); 
  +            }
  +            TextOut(lpdis->hDC, XBITMAP + 6, y, szBuf, strlen(szBuf)); 
  +            break; 
  +
  +        case ODA_FOCUS: 
  +            break; 
  +        } 
  +        return TRUE;
  +    case WM_COMMAND: 
  +        switch (LOWORD(wParam)) 
  +        { 
  +        case IDL_SERVICES:
  +            switch (HIWORD(wParam))
  +            {
  +            case LBN_DBLCLK:
  +                /* if started then stop, if stopped then start */
  +                hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +                nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0);
  +                if (nItem != LB_ERR)
  +                {
  +                    g_hBmpPicture = (HBITMAP)SendMessage(hListBox, 
  +                                                         LB_GETITEMDATA,
  +                                                         nItem, (LPARAM) 0);
  +                    if (g_hBmpPicture == g_hBmpStop) {
  +                        SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, 
  +                                    SERVICE_CONTROL_CONTINUE);
                       }
  -                    Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE);
  -                    return TRUE;
  -                case IDC_SMANAGER: 
  -                    if (g_dwOSVersion >= OS_VERSION_WIN2K)
  -                        ShellExecute(hDlg, "open", "services.msc", "/s", NULL, SW_NORMAL);
  -                    else
  -                        WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL);
  -                    return TRUE;
  -                case IDC_SEXIT: 
  -                    EndDialog( hDlg, TRUE);
  -                    SendMessage( g_hwndMain, WM_COMMAND, (WPARAM)IDM_EXIT, 0);
  -                    return TRUE;
  -                case IDC_SCONNECT: 
  -                    DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGCONNECT),
  -                                    hDlg, (DLGPROC)ConnectDlgProc);
  -                    return TRUE;
  -                case IDC_SDISCONN: 
  -                    hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  -                    nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  -                    if (nItem != LB_ERR) {
  -                        am_DisconnectComputer(g_stServices[nItem].szComputerName);
  -                        SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);                        
  +                    else {
  +                        SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, 
  +                                    SERVICE_CONTROL_STOP);
                       }
  -                    return TRUE;
  -             }
  -        break;
  -        case WM_SIZE:
  -            switch (LOWORD(wParam)) 
  -            { 
  -                case SIZE_MINIMIZED:
  -                    EndDialog(hDlg, TRUE); 
  -                    return TRUE; 
  -                break;
  +
  +                }
  +                return TRUE;
               }
  -        break;
  -        case WM_QUIT:
  -        case WM_CLOSE: 
  +            break;
  +
  +        case IDOK: 
  +            EndDialog(hDlg, TRUE); 
  +            return TRUE; 
  +
  +        case IDC_SSTART: 
  +            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), FALSE);
  +            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +            nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  +            if (nItem != LB_ERR) {
  +                SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, 
  +                            SERVICE_CONTROL_CONTINUE);
  +            }
  +            Button_Enable(GetDlgItem(hDlg, IDC_SSTART), TRUE);
  +            return TRUE;
  +
  +        case IDC_SSTOP: 
  +            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), FALSE);
  +            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +            nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  +            if (nItem != LB_ERR) {
  +                SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, 
  +                            SERVICE_CONTROL_STOP);
  +            }
  +            Button_Enable(GetDlgItem(hDlg, IDC_SSTOP), TRUE);
  +            return TRUE;
  +
  +        case IDC_SRESTART: 
  +            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), FALSE);
  +            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +            nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  +            if (nItem != LB_ERR) {
  +                SendMessage(hDlg, WM_MANAGEMESSAGE, nItem, 
  +                            SERVICE_APACHE_RESTART);
  +            }
  +            Button_Enable(GetDlgItem(hDlg, IDC_SRESTART), TRUE);
  +            return TRUE;
  +
  +        case IDC_SMANAGER: 
  +            if (g_dwOSVersion >= OS_VERSION_WIN2K) {
  +                ShellExecute(hDlg, "open", "services.msc", "/s",
  +                             NULL, SW_NORMAL);
  +            }
  +            else {
  +                WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL);
  +            }
  +            return TRUE;
  +
  +        case IDC_SEXIT: 
               EndDialog(hDlg, TRUE);
  +            SendMessage(g_hwndMain, WM_COMMAND, (WPARAM)IDM_EXIT, 0);
               return TRUE;
  -        default:
  -            return FALSE;
  +
  +        case IDC_SCONNECT: 
  +            DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGCONNECT),
  +                      hDlg, (DLGPROC)ConnectDlgProc);
  +            return TRUE;
  +
  +        case IDC_SDISCONN: 
  +            hListBox = GetDlgItem(hDlg, IDL_SERVICES); 
  +            nItem = SendMessage(hListBox, LB_GETCURSEL, 0, 0); 
  +            if (nItem != LB_ERR) {
  +                am_DisconnectComputer(g_stServices[nItem].szComputerName);
  +                SendMessage(g_hwndMain, WM_TIMER, WM_TIMER_RESCAN, 0);
  +            }
  +            return TRUE;
  +        }
  +        break;
  +
  +    case WM_SIZE:
  +        switch (LOWORD(wParam)) 
  +        { 
  +        case SIZE_MINIMIZED:
  +            EndDialog(hDlg, TRUE); 
  +            return TRUE; 
  +            break;
  +        }
  +        break;
  +
  +    case WM_QUIT:
  +    case WM_CLOSE: 
  +        EndDialog(hDlg, TRUE);
  +        return TRUE;
  +
  +    default:
  +        return FALSE;
       }
       return FALSE;
   }
  @@ -1368,156 +1503,183 @@
       }
       switch (message) 
       {
  -        case WM_CREATE:
  +    case WM_CREATE:
  +        GetApacheServicesStatus();
  +        ShowNotifyIcon(hWnd, NIM_ADD);
  +        SetTimer(hWnd, WM_TIMER_REFRESH, REFRESH_TIME, NULL);
  +        SetTimer(hWnd, WM_TIMER_RESCAN,  RESCAN_TIME, NULL);
  +        break;
  +
  +    case WM_TIMER:
  +        switch (wParam)
  +        {
  +        case WM_TIMER_RESCAN:
  +        {
  +            int nPrev = 0, nNew = 0;
  +            EnterCriticalSection(&g_stcSection);
  +            if (FindRunningServices() || g_bRescanServices)
  +            {
  +                ShowNotifyIcon(hWnd, NIM_MODIFY);
  +                if (g_hwndServiceDlg)
  +                    PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  +            }
  +            /* check if services list changed */
  +            while (g_stServices[nPrev].szServiceName != NULL)
  +                ++nPrev;
               GetApacheServicesStatus();
  -            ShowNotifyIcon(hWnd, NIM_ADD);
  -            SetTimer(hWnd, WM_TIMER_REFRESH, REFRESH_TIME, NULL);
  -            SetTimer(hWnd, WM_TIMER_RESCAN,  RESCAN_TIME, NULL);
  -            break;
  -        case WM_TIMER:
  -            switch (wParam)
  +            while (g_stServices[nNew].szServiceName != NULL)
  +                ++nNew;
  +            if (nPrev != nNew)
               {
  -                case WM_TIMER_RESCAN:
  -                {
  -                    int nPrev = 0, nNew = 0;
  -                    EnterCriticalSection(&g_stcSection);
  -                    if (FindRunningServices() || g_bRescanServices)
  -                    {
  -                        ShowNotifyIcon(hWnd, NIM_MODIFY);
  -                        if (g_hwndServiceDlg)
  -                            PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  -                    }
  -                    /* check if services list changed */
  -                    while (g_stServices[nPrev].szServiceName != NULL)
  -                        ++nPrev;
  -                    GetApacheServicesStatus();
  -                    while (g_stServices[nNew].szServiceName != NULL)
  -                        ++nNew;
  -                    if (nPrev != nNew)
  -                    {
  -                        ShowNotifyIcon(hWnd, NIM_MODIFY);
  -                        if (g_hwndServiceDlg)
  -                            PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  -                    }
  -                    LeaveCriticalSection(&g_stcSection);
  -                break;
  -                }
  -                case WM_TIMER_REFRESH:
  -                {
  -                    int nPrev = 0, nNew = 0;
  -                    EnterCriticalSection(&g_stcSection);
  -                    if (g_bRescanServices)
  -                    {       
  -                        GetApacheServicesStatus();
  -                        ShowNotifyIcon(hWnd, NIM_MODIFY);
  -                        if (g_hwndServiceDlg)
  -                            PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  -                    }
  -                    else if (FindRunningServices())
  -                    {
  -                        ShowNotifyIcon(hWnd, NIM_MODIFY);
  -                        if (g_hwndServiceDlg)
  -                            PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  -                    }
  -                    LeaveCriticalSection(&g_stcSection);
  -                    break;
  +                ShowNotifyIcon(hWnd, NIM_MODIFY);
  +                if (g_hwndServiceDlg) {
  +                    PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
                   }
               }
  +            LeaveCriticalSection(&g_stcSection);
               break;
  -        case WM_QUIT:
  -            ShowNotifyIcon(hWnd, NIM_DELETE);
  -            break;
  -        case WM_TRAYMESSAGE:
  -            switch(lParam)
  +        }
  +
  +        case WM_TIMER_REFRESH:
  +        {
  +            int nPrev = 0, nNew = 0;
  +            EnterCriticalSection(&g_stcSection);
  +            if (g_bRescanServices)
               {
  -                case WM_LBUTTONDBLCLK:
  -                   if (!g_bDlgServiceOn)
  -                   {
  -                       g_bDlgServiceOn = TRUE;
  -                       DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES),
  -                             hWnd, (DLGPROC)ServiceDlgProc);
  -                       g_bDlgServiceOn = FALSE;
  -                       g_hwndServiceDlg = NULL;
  -                   }
  -                   else if (IsWindow(g_hwndServiceDlg))
  -                   {
  -                       /* Dirty hack to bring the window to the foreground */
  -                       SetWindowPos(g_hwndServiceDlg, HWND_TOPMOST, 0, 0, 0, 0,
  -                                    SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  -                       SetWindowPos(g_hwndServiceDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
  -                                    SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  -                       SetFocus(g_hwndServiceDlg);
  -                   }
  -                break;
  -                case WM_LBUTTONUP:
  -                    ShowTryServicesMenu(hWnd);
  -                break;    
  -                case WM_RBUTTONUP:
  -                    ShowTryPopupMenu(hWnd);
  -                break;    
  +                GetApacheServicesStatus();
  +                ShowNotifyIcon(hWnd, NIM_MODIFY);
  +                if (g_hwndServiceDlg) {
  +                    PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  +                }
               }
  -            break;
  -        case WM_COMMAND:
  -            if ((LOWORD(wParam) & IDM_SM_START) == IDM_SM_START)
  +            else if (FindRunningServices())
               {
  -                ApacheManageService(g_stServices[LOWORD(wParam) - IDM_SM_START].szServiceName,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_START].szImagePath,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_START].szComputerName,
  -                                    SERVICE_CONTROL_CONTINUE);                
  -                return TRUE;
  +                ShowNotifyIcon(hWnd, NIM_MODIFY);
  +                if (g_hwndServiceDlg) {
  +                    PostMessage(g_hwndServiceDlg, WM_UPDATEMESSAGE, 0, 0);
  +                }
               }
  -            else if ((LOWORD(wParam) & IDM_SM_STOP) == IDM_SM_STOP)
  +            LeaveCriticalSection(&g_stcSection);
  +            break;
  +        }
  +        }
  +        break;
  +
  +    case WM_QUIT:
  +        ShowNotifyIcon(hWnd, NIM_DELETE);
  +        break;
  +
  +    case WM_TRAYMESSAGE:
  +        switch (lParam)
  +        {
  +        case WM_LBUTTONDBLCLK:
  +            if (!g_bDlgServiceOn)
               {
  -                ApacheManageService(g_stServices[LOWORD(wParam) - IDM_SM_STOP].szServiceName,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_STOP].szImagePath,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_STOP].szComputerName,
  -                                    SERVICE_CONTROL_STOP);                
  -                return TRUE;
  +                g_bDlgServiceOn = TRUE;
  +                DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES),
  +                          hWnd, (DLGPROC)ServiceDlgProc);
  +                g_bDlgServiceOn = FALSE;
  +                g_hwndServiceDlg = NULL;
               }
  -            else if ((LOWORD(wParam) & IDM_SM_RESTART) == IDM_SM_RESTART)
  +            else if (IsWindow(g_hwndServiceDlg))
               {
  -                ApacheManageService(g_stServices[LOWORD(wParam) - IDM_SM_RESTART].szServiceName,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_RESTART].szImagePath,
  -                                    g_stServices[LOWORD(wParam) - IDM_SM_RESTART].szComputerName,
  -                                    SERVICE_APACHE_RESTART);                
  -                return TRUE;
  +                /* Dirty hack to bring the window to the foreground */
  +                SetWindowPos(g_hwndServiceDlg, HWND_TOPMOST, 0, 0, 0, 0,
  +                             SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  +                SetWindowPos(g_hwndServiceDlg, HWND_NOTOPMOST, 0, 0, 0, 0,
  +                             SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
  +                SetFocus(g_hwndServiceDlg);
               }
  -            switch (LOWORD(wParam))
  +            break;
  +
  +        case WM_LBUTTONUP:
  +            ShowTryServicesMenu(hWnd);
  +            break;
  +
  +        case WM_RBUTTONUP:
  +            ShowTryPopupMenu(hWnd);
  +            break;
  +        }
  +        break;
  +
  +    case WM_COMMAND:
  +        if ((LOWORD(wParam) & IDM_SM_START) == IDM_SM_START)
  +        {
  +            ApacheManageService(g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_START].szServiceName,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_START].szImagePath,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_START].szComputerName,
  +                                SERVICE_CONTROL_CONTINUE);
  +            return TRUE;
  +        }
  +        else if ((LOWORD(wParam) & IDM_SM_STOP) == IDM_SM_STOP)
  +        {
  +            ApacheManageService(g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_STOP].szServiceName,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_STOP].szImagePath,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_STOP].szComputerName,
  +                                SERVICE_CONTROL_STOP);
  +            return TRUE;
  +        }
  +        else if ((LOWORD(wParam) & IDM_SM_RESTART) == IDM_SM_RESTART)
  +        {
  +            ApacheManageService(g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_RESTART].szServiceName,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_RESTART].szImagePath,
  +                                g_stServices[LOWORD(wParam) 
  +                                           - IDM_SM_RESTART].szComputerName,
  +                                SERVICE_APACHE_RESTART);
  +            return TRUE;
  +        }
  +        switch (LOWORD(wParam))
  +        {
  +        case IDM_RESTORE:
  +            if (!g_bDlgServiceOn)
               {
  -               case IDM_RESTORE:
  -                   if (!g_bDlgServiceOn)
  -                   {
  -                       g_bDlgServiceOn = TRUE;
  -                       DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES),
  -                             hWnd, (DLGPROC)ServiceDlgProc);
  -                       g_bDlgServiceOn = FALSE;
  -                       g_hwndServiceDlg = NULL;
  -                   }
  -                   else if (IsWindow(g_hwndServiceDlg))
  -                       SetFocus(g_hwndServiceDlg);
  -                   break;
  -                case IDC_SMANAGER: 
  -                    if (g_dwOSVersion >= OS_VERSION_WIN2K)
  -                        ShellExecute(NULL, "open", "services.msc", "/s", NULL, SW_NORMAL);
  -                    else
  -                        WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL);
  -                    return TRUE;
  -               case IDM_EXIT:
  -                   ShowNotifyIcon(hWnd, NIM_DELETE);
  -                   PostQuitMessage(0);
  -                   return TRUE;
  +                g_bDlgServiceOn = TRUE;
  +                DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DLGSERVICES),
  +                          hWnd, (DLGPROC)ServiceDlgProc);
  +                g_bDlgServiceOn = FALSE;
  +                g_hwndServiceDlg = NULL;
               }
  -        default:
  -            return DefWindowProc(hWnd, message, wParam, lParam);
  +            else if (IsWindow(g_hwndServiceDlg)) {
  +                SetFocus(g_hwndServiceDlg);
  +            }
  +            break;
  +
  +        case IDC_SMANAGER: 
  +            if (g_dwOSVersion >= OS_VERSION_WIN2K) {
  +                ShellExecute(NULL, "open", "services.msc", "/s",
  +                             NULL, SW_NORMAL);
  +            }
  +            else {
  +                WinExec("Control.exe SrvMgr.cpl Services", SW_NORMAL);
  +            }
  +            return TRUE;
  +
  +        case IDM_EXIT:
  +            ShowNotifyIcon(hWnd, NIM_DELETE);
  +            PostQuitMessage(0);
  +            return TRUE;
  +        }
  +
  +    default:
  +        return DefWindowProc(hWnd, message, wParam, lParam);
       }
   
       return FALSE;
   }
   
  +
   /* Create main invisible window */
   HWND CreateMainWindow(HINSTANCE hInstance)
   {
  -    HWND       hWnd = NULL;
  +    HWND hWnd = NULL;
       WNDCLASSEX wcex;
   
       if (!GetSystemOSVersion(&g_dwOSVersion))
  @@ -1533,42 +1695,40 @@
       wcex.cbClsExtra     = 0;
       wcex.cbWndExtra     = 0;
       wcex.hInstance      = hInstance;
  -    wcex.hIcon          = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON),
  -                                           IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
  +    wcex.hIcon   = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON),
  +                                    IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
       wcex.hCursor        = g_hCursorArrow;
       wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
       wcex.lpszMenuName   = 0;
       wcex.lpszClassName  = g_szWindowClass;
  -    wcex.hIconSm        = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON),
  -                                           IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  +    wcex.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APSRVMON),
  +                                    IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
   
  -    if (RegisterClassEx(&wcex))
  +    if (RegisterClassEx(&wcex)) {
           hWnd = CreateWindow(g_szWindowClass, g_szTitle,
  -                             0, 0, 0, 0, 0,
  -                             NULL, NULL, hInstance, NULL);
  -
  +                            0, 0, 0, 0, 0,
  +                            NULL, NULL, hInstance, NULL);
  +    }
       return hWnd;
   
   }
   
   
  -int WINAPI WinMain(HINSTANCE hInstance,
  -                    HINSTANCE hPrevInstance,
  -                    LPSTR lpCmdLine,
  -                    int nCmdShow)
  +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  +                   LPSTR lpCmdLine, int nCmdShow)
   {
       CHAR szTmp[MAX_LOADSTRING];
       CHAR szCmp[MAX_COMPUTERNAME_LENGTH+4];
  -    MSG     msg;
  +    MSG msg;
       /* single instance mutex */
       HANDLE hMutex;
       int i;
       DWORD d;
   
       g_LangID = GetUserDefaultLangID();
  -    if ((g_LangID & 0xFF) != LANG_ENGLISH)
  +    if ((g_LangID & 0xFF) != LANG_ENGLISH) {
           g_LangID = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
  -    
  +    }
       for (i = IDS_MSG_FIRST; i <= IDS_MSG_LAST; ++i) {
           LoadString(hInstance, i, szTmp, MAX_LOADSTRING);
           g_lpMsg[i - IDS_MSG_FIRST] = strdup(szTmp);
  @@ -1580,7 +1740,7 @@
       strupr(szCmp);
       g_szLocalHost = strdup(szCmp);
   
  -    ZeroMemory(g_stComputers, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS);
  +    memset(g_stComputers, 0, sizeof(ST_MONITORED_COMP) * MAX_APACHE_COMPUTERS);
       g_stComputers[0].szComputerName = strdup(szCmp);
       g_stComputers[0].hRegistry = HKEY_LOCAL_MACHINE;
       g_szTitle = strdup(szTmp);
  @@ -1591,40 +1751,44 @@
                                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
       g_icoRun           = LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICORUN),
                                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  -    g_hCursorHourglass = LoadImage(NULL, MAKEINTRESOURCE(OCR_WAIT), IMAGE_CURSOR,
  -                                   LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_SHARED);
  -    g_hCursorArrow     = LoadImage(NULL, MAKEINTRESOURCE(OCR_NORMAL), IMAGE_CURSOR,
  -                                   LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_SHARED);
  +    g_hCursorHourglass = LoadImage(NULL, MAKEINTRESOURCE(OCR_WAIT), 
  +                                   IMAGE_CURSOR, LR_DEFAULTSIZE, 
  +                                   LR_DEFAULTSIZE, LR_SHARED);
  +    g_hCursorArrow     = LoadImage(NULL, MAKEINTRESOURCE(OCR_NORMAL), 
  +                                   IMAGE_CURSOR, LR_DEFAULTSIZE, 
  +                                   LR_DEFAULTSIZE, LR_SHARED);
       g_hBmpStart        = LoadImage(hInstance, MAKEINTRESOURCE(IDB_BMPRUN),
  -                                   IMAGE_BITMAP, XBITMAP, YBITMAP, LR_DEFAULTCOLOR);
  +                                   IMAGE_BITMAP, XBITMAP, YBITMAP, 
  +                                   LR_DEFAULTCOLOR);
       g_hBmpStop         = LoadImage(hInstance, MAKEINTRESOURCE(IDB_BMPSTOP),
  -                                   IMAGE_BITMAP, XBITMAP, YBITMAP, LR_DEFAULTCOLOR);
  +                                   IMAGE_BITMAP, XBITMAP, YBITMAP, 
  +                                   LR_DEFAULTCOLOR);
   
       hMutex = CreateMutex(NULL, FALSE, "APSRVMON_MUTEX");
       if ((hMutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS))
       {
  -        ErrorMessage(g_lpMsg[IDS_MSG_APPRUNNING-IDS_MSG_FIRST], FALSE);
  -        if (hMutex)
  +        ErrorMessage(g_lpMsg[IDS_MSG_APPRUNNING - IDS_MSG_FIRST], FALSE);
  +        if (hMutex) {
               CloseHandle(hMutex);
  -
  +        }
           return 0;
       }
   
  -    ZeroMemory(g_stServices, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES);
  +    memset(g_stServices, 0, sizeof(ST_APACHE_SERVICE) * MAX_APACHE_SERVICES);
       CoInitialize(NULL);
       InitCommonControls();
       g_hInstance = hInstance;
       g_hwndMain = CreateMainWindow(hInstance);
       g_bUiTaskbarCreated = RegisterWindowMessage("TaskbarCreated");
       InitializeCriticalSection(&g_stcSection);
  -    g_hwndServiceDlg = NULL;                      
  +    g_hwndServiceDlg = NULL;
       if (g_hwndMain != NULL)
       {
           while (GetMessage(&msg, NULL, 0, 0) == TRUE) 
           {
               TranslateMessage(&msg);
               DispatchMessage(&msg);
  -        }    
  +        }
           am_ClearServicesSt();
       }
       am_ClearComputersSt();
  
  
  

Mime
View raw message