You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mt...@apache.org on 2004/04/07 13:23:21 UTC

cvs commit: jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr apsvcmgr.vcproj apsvcmgr.rc apsvcmgr.manifest apsvcmgr.h apsvcmgr.c

mturk       2004/04/07 04:23:21

  Added:       daemon/src/native/nt/procrun/apps/apsvcmgr apsvcmgr.vcproj
                        apsvcmgr.rc apsvcmgr.manifest apsvcmgr.h apsvcmgr.c
  Log:
  Initial upload
  
  Revision  Changes    Path
  1.1                  jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.vcproj
  
  Index: apsvcmgr.vcproj
  ===================================================================
  <?xml version="1.0" encoding="Windows-1252"?>
  <VisualStudioProject
  	ProjectType="Visual C++"
  	Version="7.10"
  	Name="apsvcmgr"
  	ProjectGUID="{3D8C70CD-F3D4-4191-89FD-7BFE2A3EDDE4}"
  	Keyword="Win32Proj">
  	<Platforms>
  		<Platform
  			Name="Win32"/>
  	</Platforms>
  	<Configurations>
  		<Configuration
  			Name="Debug|Win32"
  			OutputDirectory="..\..\obj\Debug"
  			IntermediateDirectory="..\..\obj\Debug"
  			ConfigurationType="1"
  			CharacterSet="2">
  			<Tool
  				Name="VCCLCompilerTool"
  				Optimization="0"
  				AdditionalIncludeDirectories=".\;..\..\include"
  				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
  				MinimalRebuild="TRUE"
  				BasicRuntimeChecks="3"
  				RuntimeLibrary="3"
  				BufferSecurityCheck="TRUE"
  				UsePrecompiledHeader="0"
  				WarningLevel="3"
  				Detect64BitPortabilityProblems="TRUE"
  				DebugInformationFormat="4"/>
  			<Tool
  				Name="VCCustomBuildTool"/>
  			<Tool
  				Name="VCLinkerTool"
  				AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
  				OutputFile="../../bin/apsvcmgrd.exe"
  				LinkIncremental="2"
  				GenerateDebugInformation="TRUE"
  				ProgramDatabaseFile="$(OutDir)/apsvcmgr.pdb"
  				SubSystem="2"
  				EntryPointSymbol=""
  				TargetMachine="1"/>
  			<Tool
  				Name="VCMIDLTool"/>
  			<Tool
  				Name="VCPostBuildEventTool"/>
  			<Tool
  				Name="VCPreBuildEventTool"/>
  			<Tool
  				Name="VCPreLinkEventTool"/>
  			<Tool
  				Name="VCResourceCompilerTool"
  				AdditionalIncludeDirectories="..\..\include"/>
  			<Tool
  				Name="VCWebServiceProxyGeneratorTool"/>
  			<Tool
  				Name="VCXMLDataGeneratorTool"/>
  			<Tool
  				Name="VCWebDeploymentTool"/>
  			<Tool
  				Name="VCManagedWrapperGeneratorTool"/>
  			<Tool
  				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
  		</Configuration>
  		<Configuration
  			Name="Release|Win32"
  			OutputDirectory="..\..\obj\Release"
  			IntermediateDirectory="..\..\obj\Release"
  			ConfigurationType="1"
  			CharacterSet="2">
  			<Tool
  				Name="VCCLCompilerTool"
  				AdditionalIncludeDirectories=".\;..\..\include"
  				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
  				RuntimeLibrary="0"
  				BufferSecurityCheck="TRUE"
  				UsePrecompiledHeader="0"
  				WarningLevel="3"
  				Detect64BitPortabilityProblems="TRUE"
  				DebugInformationFormat="3"/>
  			<Tool
  				Name="VCCustomBuildTool"/>
  			<Tool
  				Name="VCLinkerTool"
  				AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
  				OutputFile="../../bin/apsvcmgr.exe"
  				LinkIncremental="1"
  				GenerateDebugInformation="FALSE"
  				SubSystem="2"
  				OptimizeReferences="2"
  				EnableCOMDATFolding="2"
  				EntryPointSymbol=""
  				TargetMachine="1"/>
  			<Tool
  				Name="VCMIDLTool"/>
  			<Tool
  				Name="VCPostBuildEventTool"/>
  			<Tool
  				Name="VCPreBuildEventTool"/>
  			<Tool
  				Name="VCPreLinkEventTool"/>
  			<Tool
  				Name="VCResourceCompilerTool"
  				AdditionalIncludeDirectories="..\..\include"/>
  			<Tool
  				Name="VCWebServiceProxyGeneratorTool"/>
  			<Tool
  				Name="VCXMLDataGeneratorTool"/>
  			<Tool
  				Name="VCWebDeploymentTool"/>
  			<Tool
  				Name="VCManagedWrapperGeneratorTool"/>
  			<Tool
  				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
  		</Configuration>
  		<Configuration
  			Name="Debug Unicode|Win32"
  			OutputDirectory="..\..\obj\$(ConfigurationName)"
  			IntermediateDirectory="..\..\obj\$(ConfigurationName)"
  			ConfigurationType="1"
  			CharacterSet="1">
  			<Tool
  				Name="VCCLCompilerTool"
  				Optimization="0"
  				AdditionalIncludeDirectories=".\;..\..\include"
  				PreprocessorDefinitions="WIN32;_DEBUG;_UNICODE;_WINDOWS"
  				MinimalRebuild="TRUE"
  				BasicRuntimeChecks="3"
  				RuntimeLibrary="3"
  				BufferSecurityCheck="TRUE"
  				UsePrecompiledHeader="0"
  				WarningLevel="3"
  				Detect64BitPortabilityProblems="TRUE"
  				DebugInformationFormat="4"/>
  			<Tool
  				Name="VCCustomBuildTool"/>
  			<Tool
  				Name="VCLinkerTool"
  				AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
  				OutputFile="../../bin/apsvcmgrud.exe"
  				LinkIncremental="2"
  				GenerateDebugInformation="TRUE"
  				ProgramDatabaseFile="$(OutDir)/apsvcmgr.pdb"
  				SubSystem="2"
  				EntryPointSymbol=""
  				TargetMachine="1"/>
  			<Tool
  				Name="VCMIDLTool"/>
  			<Tool
  				Name="VCPostBuildEventTool"/>
  			<Tool
  				Name="VCPreBuildEventTool"/>
  			<Tool
  				Name="VCPreLinkEventTool"/>
  			<Tool
  				Name="VCResourceCompilerTool"
  				AdditionalIncludeDirectories="..\..\include"/>
  			<Tool
  				Name="VCWebServiceProxyGeneratorTool"/>
  			<Tool
  				Name="VCXMLDataGeneratorTool"/>
  			<Tool
  				Name="VCWebDeploymentTool"/>
  			<Tool
  				Name="VCManagedWrapperGeneratorTool"/>
  			<Tool
  				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
  		</Configuration>
  		<Configuration
  			Name="Release Unicode|Win32"
  			OutputDirectory="..\..\obj\$(ConfigurationName)"
  			IntermediateDirectory="..\..\obj\$(ConfigurationName)"
  			ConfigurationType="1"
  			CharacterSet="1">
  			<Tool
  				Name="VCCLCompilerTool"
  				AdditionalIncludeDirectories=".\;..\..\include"
  				PreprocessorDefinitions="WIN32;NDEBUG;_UNICODE;_WINDOWS"
  				RuntimeLibrary="0"
  				BufferSecurityCheck="TRUE"
  				UsePrecompiledHeader="0"
  				WarningLevel="3"
  				Detect64BitPortabilityProblems="TRUE"
  				DebugInformationFormat="3"/>
  			<Tool
  				Name="VCCustomBuildTool"/>
  			<Tool
  				Name="VCLinkerTool"
  				AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
  				OutputFile="../../bin/apsvcmgru.exe"
  				LinkIncremental="1"
  				GenerateDebugInformation="FALSE"
  				SubSystem="2"
  				OptimizeReferences="2"
  				EnableCOMDATFolding="2"
  				EntryPointSymbol=""
  				TargetMachine="1"/>
  			<Tool
  				Name="VCMIDLTool"/>
  			<Tool
  				Name="VCPostBuildEventTool"/>
  			<Tool
  				Name="VCPreBuildEventTool"/>
  			<Tool
  				Name="VCPreLinkEventTool"/>
  			<Tool
  				Name="VCResourceCompilerTool"
  				AdditionalIncludeDirectories="..\..\include"/>
  			<Tool
  				Name="VCWebServiceProxyGeneratorTool"/>
  			<Tool
  				Name="VCXMLDataGeneratorTool"/>
  			<Tool
  				Name="VCWebDeploymentTool"/>
  			<Tool
  				Name="VCManagedWrapperGeneratorTool"/>
  			<Tool
  				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
  		</Configuration>
  	</Configurations>
  	<References>
  	</References>
  	<Files>
  		<Filter
  			Name="Source Files"
  			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
  			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
  			<File
  				RelativePath=".\apsvcmgr.c">
  			</File>
  		</Filter>
  		<Filter
  			Name="Header Files"
  			Filter="h;hpp;hxx;hm;inl;inc;xsd"
  			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
  			<File
  				RelativePath=".\apsvcmgr.h">
  			</File>
  		</Filter>
  		<Filter
  			Name="Resource Files"
  			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
  			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
  			<File
  				RelativePath=".\apsvcmgr.rc">
  			</File>
  		</Filter>
  	</Files>
  	<Globals>
  	</Globals>
  </VisualStudioProject>
  
  
  
  1.1                  jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.rc
  
  Index: apsvcmgr.rc
  ===================================================================
  /* Copyright 2000-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
   
  #include "apxwin.h"
  #include "apsvcmgr.h"
  
  #define RSTR_ASM        "Apache Service Manager"
  #define RSTR_SCMATS     "Service Manager is attempting to "
  
  IDI_MAINICON         ICON                   "../../resources/apsvcmgr.ico" 
  IDB_TOOLBAR          BITMAP  DISCARDABLE    "../../resources/toolbar.bmp"
  IDB_SSTATUS          BITMAP  DISCARDABLE    "../../resources/sstatus.bmp"
  IDB_SUSERS           BITMAP  DISCARDABLE    "../../resources/susers.bmp"
  IDR_LICENSE          RTF                    "../../resources/license.rtf"
  BMP_JAKARTA          BITMAP                 "../../resources/jakarta.bmp"
   
  CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "apsvcmgr.manifest"
  
  IDC_APPLICATION MENU 
  BEGIN
      POPUP "&Action"
      BEGIN
          MENUITEM "&Minimize to try",            IDAM_TRY
          MENUITEM SEPARATOR
          MENUITEM "&New",                        IDAM_NEW
          MENUITEM "&Delete",                     IDAM_DELETE, GRAYED
          MENUITEM SEPARATOR
          MENUITEM "&Save                       CRTL+S", IDAM_SAVE
          MENUITEM "Save &As...              CTRL+A", IDAM_SAVEAS
          MENUITEM SEPARATOR
          MENUITEM "E&xit",                       IDAM_EXIT
      END
      POPUP "&Service"
      BEGIN
          MENUITEM "P&ropeties ...",               IDMS_PROPERTIES, GRAYED
          MENUITEM SEPARATOR
          MENUITEM "&Start",                       IDMS_START, GRAYED
          MENUITEM "S&top",                        IDMS_STOP, GRAYED
          MENUITEM "&Pause",                       IDMS_PAUSE, GRAYED
          MENUITEM "Res&tart",                     IDMS_RESTART, GRAYED
          MENUITEM SEPARATOR
          MENUITEM "Re&fresh",                     IDMS_REFRESH
          MENUITEM SEPARATOR
          MENUITEM "&Help",                        IDMS_HELP
      END
      POPUP "&View"
      BEGIN
          MENUITEM "Re&fresh Now      F5",         IDMS_REFRESH
          POPUP "Update speed"
          BEGIN
              MENUITEM "10 Seconds",              IDMV_UFAST
              MENUITEM "1    Minute",             IDMV_USLOW
              MENUITEM "Paused",                  IDMV_UPAUSED
          END
          MENUITEM SEPARATOR
          MENUITEM "Select Columns ...",          IDMV_SELECTCOLUMNS
          MENUITEM "Filter Services ...",         IDMV_FILTER
      END
      POPUP "&Help"
      BEGIN
          MENUITEM "&Help ...",                   IDMH_HELP
          MENUITEM "&About",                      IDMH_ABOUT
      END
  END
  
  IDM_POPUPMENU MENU DISCARDABLE 
  BEGIN
      POPUP "Popup Menu"
      BEGIN
          MENUITEM "Propeties ...",              IDMS_PROPERTIES, GRAYED
          MENUITEM SEPARATOR
          MENUITEM "Start",                      IDMS_START, GRAYED
          MENUITEM "Stop",                       IDMS_STOP, GRAYED
          MENUITEM "Pause",                      IDMS_PAUSE, GRAYED
          MENUITEM "Restart",                    IDMS_RESTART, GRAYED
          MENUITEM SEPARATOR
          MENUITEM "Refresh",                    IDMS_REFRESH
          MENUITEM SEPARATOR
          MENUITEM "Help",                       IDMS_HELP, HELP
      END
  END
  
  IDD_ABOUTBOX DIALOGEX 0, 0, 337, 187
  STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
  CAPTION "Apache Service Manager"
  FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
  BEGIN
      DEFPUSHBUTTON   "&OK",IDOK,285,150,50,14
      CONTROL         "",IDC_LICENSE,"RichEdit20A",ES_MULTILINE | 
                      ES_READONLY | WS_BORDER | WS_VSCROLL,0,31,335,115
      CONTROL         "BMP_JAKARTA",IDC_STATIC,"Static",SS_BITMAP,0,0,337,30
      LTEXT           " ",IDC_ABOUTAPP,2,150,270,12
      LTEXT           "Copyright � 2000-2003 The Apache Software Foundation.",IDC_STATIC,2,160,270,12
      LTEXT           "http://www.jakarta.org",IDC_STATIC,2,170,270,12 
      PUSHBUTTON      "&System Info",IAB_SYSINF,285,170,50,14
  END
  
  IDD_PROGRESS DIALOGEX 0, 0, 322, 92
  STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | 
      WS_CAPTION | WS_SYSMENU
  EXSTYLE WS_EX_TOPMOST
  CAPTION "Apache Service Manager"
  FONT 8, "MS Shell Dlg", 400, 0, 0x1
  BEGIN
      DEFPUSHBUTTON   "Cl&ose",IDOK,261,73,50,14
      PUSHBUTTON      "&Cancel",IDCANCEL,202,73,50,14
      LTEXT           " ",
                      IDDP_HEAD,40,4,250,8
      LTEXT           " ",IDDP_TEXT,40,15,250,44
      CONTROL         "",IDDP_PROGRESS,"msctls_progress32",WS_BORDER,10,50,302,
                      14
      ICON            IDI_MAINICON,IDC_STATIC,10,4,20,20,0,WS_EX_TRANSPARENT
  END
  
  IDD_PROPPAGE_SGENERAL DIALOGEX 0, 0, 260, 186
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
  FONT 8, "MS Shell Dlg", 0, 0, 0x0
  BEGIN
      LTEXT           "Service Name: ",IDC_STATIC,10,8,52,8
      LTEXT           "  ",IDC_PPSGNAME,70,8,240,8
      LTEXT           "Display &name: ",IDC_STATIC,10,23,50,8
      EDITTEXT        IDC_PPSGDISP,70,22,180,14,ES_AUTOHSCROLL
      LTEXT           "&Description: ",IDC_STATIC,10,41,43,8
      EDITTEXT        IDC_PPSGDESC,70,40,180,14,ES_AUTOHSCROLL
      LTEXT           "Pat&h to executable:",IDC_STATIC,10,63,66,8
      EDITTEXT        IDC_PPSGDEXE,10,75,240,14,ES_AUTOHSCROLL | WS_DISABLED
      LTEXT           "Startup typ&e:",IDC_STATIC,10,94,46,8
      COMBOBOX        IDC_PPSGCMBST,70,93,180,80,CBS_DROPDOWNLIST | WS_VSCROLL | 
                      WS_TABSTOP
      CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,128,240,1                    
      LTEXT           "Service Status:",IDC_STATIC,10,138,52,8
      LTEXT           "  ",IDC_PPSGSTATUS,70,138,240,8
      PUSHBUTTON      "&Start",IDC_PPSGSTART,10,160,55,14,WS_DISABLED
      PUSHBUTTON      "S&top",IDC_PPSGSTOP,71,160,55,14,WS_DISABLED
      PUSHBUTTON      "&Pause",IDC_PPSGPAUSE,132,160,55,14,WS_DISABLED
      PUSHBUTTON      "&Restart",IDC_PPSGRESTART,193,160,55,14,WS_DISABLED
  END
  
  IDD_PROPPAGE_LOGON DIALOGEX 0, 0, 260, 186
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
  FONT 8, "MS Shell Dlg", 0, 0, 0x0
  BEGIN
      LTEXT           "Log on as:",IDC_STATIC,10,8,51,8
      CONTROL         "&Local System account",IDC_PPSLLS,"Button",
                      BS_AUTORADIOBUTTON,10,23,85,10
      CONTROL         "Allo&w service to interact with desktop",IDC_PPSLID,
                      "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,37,135,10
      CONTROL         "&This account:",IDC_PPSLUA,"Button",BS_AUTORADIOBUTTON,
                      10,59,61,10
      EDITTEXT        IDC_PPSLUSER,86,58,114,14,ES_AUTOHSCROLL
      PUSHBUTTON      "&Browse...",IDC_PPSLBROWSE,205,58,50,14
      LTEXT           "&Password:",IDL_PPSLPASS,21,76,36,8
      EDITTEXT        IDC_PPSLPASS,86,75,114,14,ES_PASSWORD | ES_AUTOHSCROLL
      LTEXT           "&Confirm Password:",IDL_PPSLCPASS,20,93,63,8
      EDITTEXT        IDC_PPSLCPASS,86,92,114,14,ES_PASSWORD | ES_AUTOHSCROLL
  END
  
  IDD_FILTER DIALOGEX 0, 0, 296, 199
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
  EXSTYLE WS_EX_CONTEXTHELP
  CAPTION "Service display filters"
  FONT 8, "MS Shell Dlg", 400, 0, 0x1
  BEGIN
      LTEXT           "Enter multiple filter match strings separated by the ';' character. '*' is a wildcard.",
                      IDC_STATIC,10,7,278,8
      DEFPUSHBUTTON   "&OK",IDOK,232,175,50,14
      PUSHBUTTON      "&Cancel",IDCANCEL,176,175,50,14
      GROUPBOX        " Service name filters ",IDC_STATIC,10,28,275,62
      LTEXT           "Include:",IDC_STATIC,18,48,27,8
      EDITTEXT        IDC_FINAME,63,46,211,14,ES_AUTOHSCROLL
      LTEXT           "Exclude:",IDC_STATIC,18,66,28,8
      EDITTEXT        IDC_FXNAME,63,64,211,14,ES_AUTOHSCROLL
      GROUPBOX        "Service image path filters",IDC_STATIC,10,102,275,62
      LTEXT           "Include:",IDC_STATIC,17,120,27,8
      EDITTEXT        IDC_FISIMG,63,118,211,14,ES_AUTOHSCROLL
      LTEXT           "Exclude:",IDC_STATIC,17,138,28,8
      EDITTEXT        IDC_FXSIMG,63,136,211,14,ES_AUTOHSCROLL
  END
  
  IDD_SELCOL DIALOGEX 0, 0, 220, 130
  STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | 
      WS_SYSMENU
  CAPTION "Select Columns"
  FONT 8, "MS Shell Dlg", 400, 0, 0x1
  BEGIN
      DEFPUSHBUTTON   "OK",IDOK,156,105,50,14
      PUSHBUTTON      "Cancel",IDCANCEL,96,105,50,14
      LTEXT           "Select the columns that will apear on the Service view of the Service Manager",
                      IDC_STATIC,16,2,194,16
      CONTROL         "Name",IDC_CCOL1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
                      16,26,83,10
      CONTROL         "Description",IDC_CCOL2,"Button",BS_AUTOCHECKBOX | 
                      WS_TABSTOP,16,39,83,10
      CONTROL         "Startup Type",IDC_CCOL3,"Button",BS_AUTOCHECKBOX | 
                      WS_TABSTOP,16,52,83,10
      CONTROL         "Log On As",IDC_CCOL4,"Button",BS_AUTOCHECKBOX | 
                      WS_TABSTOP,16,65,83,10
      CONTROL         "Process Id",IDC_CCOL5,"Button",BS_AUTOCHECKBOX | 
                      WS_TABSTOP,16,78,83,10
  END
  
  IDD_SELUSER DIALOGEX 0, 0, 410, 201
  STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU |
      WS_THICKFRAME
  EXSTYLE WS_EX_CONTEXTHELP
  CAPTION "Select User"
  FONT 8, "MS Shell Dlg", 400, 0, 0x1
  BEGIN
      LTEXT           "Name:",IDSU_SELNAME,10,183,22,8
      EDITTEXT        IDSU_SELECTED,48,200,213,14,ES_AUTOHSCROLL
      DEFPUSHBUTTON   "OK",IDOK,292,180,50,14,WS_DISABLED
      PUSHBUTTON      "Cancel",IDCANCEL,348,180,50,14
      LTEXT           "Look In:",IDC_STATIC,10,9,27,8
      CONTROL         "",IDSU_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | 
                      LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | 
                      WS_TABSTOP,0,26,410,149,WS_EX_CLIENTEDGE
      CONTROL         "",IDSU_COMBO,"ComboBoxEx32",CBS_DROPDOWNLIST | 
                      WS_VSCROLL | WS_TABSTOP,47,6,260,80
  END
  
  IDC_APPLICATION ACCELERATORS 
  BEGIN
      "/",            IDMH_ABOUT,              ASCII,  ALT, NOINVERT
      "?",            IDMH_ABOUT,              ASCII,  ALT, NOINVERT
      VK_F1,          IDMH_HELP,               VIRTKEY, NOINVERT
      "S",            IDAM_SAVE,               VIRTKEY, CONTROL, NOINVERT
      "A",            IDAM_SAVEAS,             VIRTKEY, CONTROL, NOINVERT    
      "F",            IDMV_FILTER,             VIRTKEY, CONTROL, NOINVERT    
      VK_F5,          IDMS_REFRESH,            VIRTKEY, NOINVERT
  END
  
  
  STRINGTABLE 
  BEGIN
      IDS_APPLICATION     RSTR_ASM
      IDS_APPVERSION      "Version 1.0.0"
      IDS_APPFULLNAME     RSTR_ASM " Version " PRG_VERSION
      IDS_APPCOPYRIGHT    "Copyright � 2000-2003 The Apache Software Foundation"
      IDS_APPDESCRIPTION  "Apache NT Service Management Tool"
      IDS_HSSTART         RSTR_SCMATS "start the following service ..."
      IDS_HSSTOP          RSTR_SCMATS "stop the following service ..."
      IDS_HSRESTART       RSTR_SCMATS "to restart the following service ..."
      IDS_HSPAUSE         RSTR_SCMATS "to pause the following service ..."
      
      IDAM_NEW            "New Service"
      IDAM_DELETE         "Delete Service"
      IDAM_SAVE           "Export List"
      IDMS_REFRESH        "Refresh"
      IDMV_FILTER         "Filter Services"
      IDMS_PROPERTIES     "Properties"
      IDMS_START          "Start Service"
      IDMS_STOP           "Stop Service"
      IDMS_PAUSE          "Pause Service"
      IDMS_RESTART        "Restart Service"
      IDMH_HELP           "Help"    
      
      IDS_DELSERVICEC     "Confirm Delete Service"
      IDS_DELSERVICET     "You cannot undo the effects of this dialog box!\r\n\r\nYou are about to delete '%s' service.\r\nDeleting services may cause your system unusable.\r\n\r\nDo you want to proceed?"
      IDS_VALIDPASS       "Please enter a valid password"    
      IDS_PPGENERAL       "General"
      IDS_PPLOGON         "Log On"
      IDS_NOTIMPLEMENTED  "Sorry, but this feature is not implemented yet"
  END
   
  
  1 VERSIONINFO
   FILEVERSION 1,0,0,0
   PRODUCTVERSION 1,0,0,0
   FILEFLAGSMASK 0x3fL
  #if defined(_DEBUG)
   FILEFLAGS 0x03L
  #else
   FILEFLAGS 0x02L
  #endif
   FILEOS 0x40004L
   FILETYPE 0x1L
   FILESUBTYPE 0x0L
  BEGIN
    BLOCK "StringFileInfo"
    BEGIN
      BLOCK "040904b0"
      BEGIN
        VALUE "Comments", "NT Service Management Tool\0"
        VALUE "CompanyName", "Apache Software Foundation\0"
        VALUE "FileDescription", RSTR_ASM "\0"
        VALUE "FileVersion", PRG_VERSION
        VALUE "InternalName", RSTR_ASM "\0"
        VALUE "LegalCopyright", "Copyright � 2000-2003 The Apache Software Foundation.\0"
        VALUE "OriginalFilename", "apsvcmgr.exe\0"
        VALUE "ProductName", RSTR_ASM "\0"
        VALUE "ProductVersion", PRG_VERSION
      END
    END
    BLOCK "VarFileInfo"
    BEGIN
      VALUE "Translation", 0x409, 1200
    END
  END 
  
  
  
  1.1                  jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.manifest
  
  Index: apsvcmgr.manifest
  ===================================================================
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
  <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="Apache.Procrun.Apsvcmgr" type="win32" /> 
  <description>Your application description here.</description> 
  <dependency> 
  <dependentAssembly> 
  <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> 
  </dependentAssembly> 
  </dependency> 
  </assembly> 
  
  
  
  1.1                  jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.h
  
  Index: apsvcmgr.h
  ===================================================================
  /* Copyright 2000-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
   
  #undef  PRG_VERSION
  #define PRG_VERSION    "1.0.0.0" 
  
  #define NUMTOOLBUTTONS                  17
  #define IDC_TOOLBAR                     2000
  #define IDB_TOOLBAR                     2001
  #define IDB_SSTATUS                     2002
  #define IDC_LISTVIEW                    2003
  
  #define IDM_ARROWUP                     2004
  #define IDM_ARROWDOWN                   2005
  #define IDS_HSSTART                     2006
  #define IDS_HSSTOP                      2007
  #define IDS_HSPAUSE                     2008
  #define IDS_HSRESTART                   2009
  #define IDM_POPUPMENU                   2010
  
  #define IDAM_TRY                        2100
  #define IDAM_SAVE                       2101
  #define IDAM_SAVEAS                     2102
  #define IDAM_EXIT                       2103
  #define IDAM_NEW                        2104
  #define IDAM_DELETE                     2105
  
  #define IDMS_START                      2110
  #define IDMS_STOP                       2111
  #define IDMS_PAUSE                      2112
  #define IDMS_RESTART                    2113
  #define IDMS_REFRESH                    2114
  #define IDMS_PROPERTIES                 2115
  #define IDMS_HELP                       2116
  
  #define IDMV_UFAST                      2120
  #define IDMV_USLOW                      2121
  #define IDMV_UPAUSED                    2122
  #define IDMV_SELECTCOLUMNS              2123
  #define IDMV_FILTER                     2124
  
  #define IDMH_HELP                       2130
  #define IDMH_ABOUT                      2131
  
  /* Property pages */
  
  #define IDD_PROPPAGE_SGENERAL           2600
  #define IDC_PPSGNAME                    2601
  #define IDC_PPSGDISP                    2602
  #define IDC_PPSGDESC                    2603
  #define IDC_PPSGDEXE                    2604
  #define IDC_PPSGCMBST                   2605
  #define IDC_PPSGSTATUS                  2606
  #define IDC_PPSGSTART                   2607
  #define IDC_PPSGSTOP                    2608
  #define IDC_PPSGPAUSE                   2609
  #define IDC_PPSGRESTART                 2610
  
  #define IDD_PROPPAGE_LOGON              2620
  #define IDC_PPSLLS                      2621
  #define IDC_PPSLID                      2622
  #define IDC_PPSLUA                      2623
  #define IDC_PPSLUSER                    2624
  #define IDC_PPSLBROWSE                  2625
  #define IDC_PPSLPASS                    2626
  #define IDC_PPSLCPASS                   2627
  #define IDL_PPSLPASS                    2628
  #define IDL_PPSLCPASS                   2629
  
  
  #define IDD_FILTER                      2640
  #define IDC_FINAME                      2641
  #define IDC_FXNAME                      2642
  #define IDC_FISIMG                      2643
  #define IDC_FXSIMG                      2644
  
  #define IDD_SELCOL                      2650
  #define IDC_CCOL1                       2651
  #define IDC_CCOL2                       2652
  #define IDC_CCOL3                       2653
  #define IDC_CCOL4                       2654
  #define IDC_CCOL5                       2655
  
  
  #if 0
  #define IDAMS_NEW                       3000
  #define IDAMS_DELETE                    3001
  #define IDAMS_SAVE                      3002
  #define IDMVS_REFRESH                   3003
  #define IDMSS_PROPERTIES                3004
  #define IDMSS_START                     3005
  #define IDMSS_STOP                      3006
  #define IDMSS_PAUSE                     3007
  #define IDMSS_RESTART                   3008
  #define IDMHS_HELP                      3009    
  #define IDMVS_FILTER                    3010
  #endif
  
  #define IDS_DELSERVICEC                 3100
  #define IDS_DELSERVICET                 3101
  #define IDS_VALIDPASS                   3102
  #define IDS_PPGENERAL                   3103
  #define IDS_PPLOGON                     3104
  #define IDS_NOTIMPLEMENTED              3105
  
  
  
  
  1.1                  jakarta-commons/daemon/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c
  
  Index: apsvcmgr.c
  ===================================================================
  /* Copyright 2000-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
   
  #include "apxwin.h"
  #include "apsvcmgr.h"
  
  LPAPXGUISTORE _gui_store  = NULL;
  HWND          hWndToolbar = NULL;
  HWND          hWndList    = NULL;
  HWND          hWndListHdr = NULL;
  WNDPROC       ListViewWinMain;
  WNDPROC       ListViewWinHead;
  HWND          hWndStatus  = NULL;
  HWND          hWndModal   = NULL;
  LVHITTESTINFO lvLastHit;
  int           lvHitItem = -1;
  /* Toolbar buttons 
   * TODO: Localize...
   */
  TBBUTTON tbButtons[] = {
      { 4, IDAM_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
      { 5, IDAM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
      { 7, IDMS_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
      {16, IDMV_FILTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
      { 8, IDAM_DELETE, 0, TBSTYLE_BUTTON, 0, 0},
      { 6, IDMS_PROPERTIES, 0, TBSTYLE_BUTTON, 0, 0},
      { 0, IDMS_START, 0, TBSTYLE_BUTTON, 0, 0},
      { 1, IDMS_STOP, 0, TBSTYLE_BUTTON, 0, 0},
      { 2, IDMS_PAUSE, 0, TBSTYLE_BUTTON, 0, 0},
      { 3, IDMS_RESTART, 0, TBSTYLE_BUTTON, 0, 0},
      { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
      {11, IDMH_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}
  };
  
  APXLVITEM lvItems[] = {
      { 0, FALSE, 80,  80, LVCFMT_LEFT, TEXT("Status") },
      { 0, TRUE, 120, 120, LVCFMT_LEFT, TEXT("Name") },
      { 0, TRUE, 240, 240, LVCFMT_LEFT, TEXT("Description") },
      { 0, TRUE,  80,  80, LVCFMT_LEFT, TEXT("Startup Type") },
      { 0, TRUE,  80,  80, LVCFMT_LEFT, TEXT("Log On As") },
      { 0, FALSE, 80,  80, LVCFMT_RIGHT, TEXT("Process Id") },
      { 0, FALSE,  0,  80, LVCFMT_RIGHT, TEXT("# Handles") }
  };
  
  #define NUMTBBUTTONS  (sizeof(tbButtons) / sizeof(tbButtons[0]))
  #define NUMLVITEMS    (sizeof(lvItems) / sizeof(lvItems[0]))
  
  #define APSVCMGR_CLASS      TEXT("APSVCMGR")
  
  /* Display only Started/Paused status */
  #define STAT_STARTED        TEXT("Started")
  #define STAT_PAUSED         TEXT("Paused")
  #define STAT_STOPPED        TEXT("Stopped")
  #define STAT_DISABLED       TEXT("Disabled")
  #define STAT_NONE           TEXT("")
  #define STAT_SYSTEM         L"LocalSystem"
  
  #define START_AUTO           L"Automatic"
  #define START_MANUAL         L"Manual"
  #define START_DISABLED       L"Disabled"
  #define START_BOOT           L"Boot"
  #define START_SYSTEM         L"SystemInit"
  
  #define SFILT_KEY            L"Filters"
  #define SFILT_INAME          L"IncludeName"
  #define SFILT_XNAME          L"ExcludeName"
  #define SFILT_ISIMG          L"IncludeImage"
  #define SFILT_XSIMG          L"ExcludeImage"
  
  #define DISPLAY_KEY          "Display"
  #define DISPLAY_STATE        "GuiState"
  #define EMPTY_PASSWORD       L"               "
  #define EXPORT_TITLE         "Export Services list"
  #define EXPORT_EXTFILT       "Comma separated (*.csv)\0*.csv\0Tab Delimited (*.tab)\0*.txt\0All Files(*.*)\0*.*\0"
  
  
  #define WM_TIMER_REFRESH    10
  #define WM_USER_LREFRESH    WM_USER + 1
  #define UPD_FAST            10000
  #define UPD_SLOW            60000
  
  static int _toolbarHeight = 0;
  static int _statbarHeight = 0;
  static int _currentTimer  = IDMV_UPAUSED;
  static int _currentLitem  = 0;
  static int _listviewCols  = 0;
  static int _sortOrder     = 1;
  static int _sortColumn    = 1;
  static LPAPXSERVENTRY     _currentEntry = NULL;
  
  static LPWSTR   _filterIname    = NULL;
  static LPWSTR   _filterXname    = NULL;
  static LPWSTR   _filterIimage   = NULL;
  static LPWSTR   _filterXimage   = NULL;
  static LPSTR    _exportFilename = NULL;
  static DWORD    _exportIndex    = 0;
  /* Main application pool */
  APXHANDLE hPool     = NULL;
  APXHANDLE hService  = NULL;
  APXHANDLE hRegistry = NULL;
  
  /* Service browse callback declaration */
  BOOL ServiceCallback(APXHANDLE hObject, UINT uMsg,
                       WPARAM wParam, LPARAM lParam);
  
  int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  {
      WCHAR  szA[1024] = {0};
      WCHAR  szB[1024] = {0};
      int    rc;
      ListView_GetItemTextW(hWndList, (INT)lParam1, _sortColumn, szA, 1023);
      ListView_GetItemTextW(hWndList, (INT)lParam2, _sortColumn, szB, 1023);
      rc = lstrcmpW(szA, szB);
  
      return rc * _sortOrder;
  }
  
  void DestroyListView()
  {
      int i, x;
      
      x = ListView_GetItemCount(hWndList);
      if (x > 0) {
          LV_ITEM lvI;
          lvI.mask = LVIF_PARAM;
          for (i = 0; i < x; i++) {
              lvI.iItem  = i;
              lvI.lParam = 0;
              ListView_GetItem(hWndList, &lvI);
              if (lvI.lParam) {
                  LPAPXSERVENTRY lpEnt = (LPAPXSERVENTRY)lvI.lParam;
                  apxFree(lpEnt->lpConfig);
                  apxFree(lpEnt);
              }
          }
      }
      ListView_DeleteAllItems(hWndList);
      _currentLitem = 0;
  }
  
  BOOL ExportListView(LPCSTR szFileName, DWORD dwIndex)
  {
      int i, j, x;
      CHAR szI[SIZ_DESLEN];
      HANDLE hFile;
      DWORD  dwWriten;
      LPSTR  szD;
      hFile = CreateFileA(szFileName, 
                          GENERIC_WRITE,
                          0,
                          NULL,
                          CREATE_ALWAYS,
                          FILE_ATTRIBUTE_NORMAL,
                          NULL);
      if (IS_INVALID_HANDLE(hFile))
          return FALSE;
      x = ListView_GetItemCount(hWndList);
      if (x > 0) {
          LV_ITEM lvI;
          lvI.mask = LVIF_PARAM;
  
          if (dwIndex == 1)
              szD = ";";
          else
              szD = "\t";
          WriteFile(hFile, "ServiceName", sizeof("ServiceName") - 1, &dwWriten, NULL);
          for (i = 1; i <  NUMLVITEMS; i++) {
              if (lvItems[i].iWidth) {
  #ifdef _UNICODE
                  WideToAscii(lvItems[i].szLabel, szI);
  #else
                  lstrcpyA(szI, lvItems[i].szLabel);
  #endif
                  WriteFile(hFile, szD, 1, &dwWriten, NULL);
                  WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
              }
          }
          WriteFile(hFile, "\r\n", 2, &dwWriten, NULL);           
          for (i = 0; i < x; i++) {
              lvI.iItem  = i;
              lvI.lParam = 0;
              ListView_GetItem(hWndList, &lvI);
              if (lvI.lParam) {
                  LPAPXSERVENTRY lpEnt = (LPAPXSERVENTRY)lvI.lParam;
                  WideToAscii(lpEnt->szServiceName, szI);
                  WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
                  WriteFile(hFile, szD, 1, &dwWriten, NULL);
                  
              }
              for (j = 1; j < _listviewCols - 1; j++) {
                  szI[0] = '\0';
                  ListView_GetItemTextA(hWndList, i, j, szI, SIZ_DESMAX);
                  if (szI[0])
                      WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
                  WriteFile(hFile, szD, 1, &dwWriten, NULL);
              }
              szI[0] = '\0';
              ListView_GetItemTextA(hWndList, i, j, szI, SIZ_DESMAX);
              if (szI[0])
                  WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
              WriteFile(hFile, "\r\n", 2, &dwWriten, NULL);           
          }
      }  
      CloseHandle(hFile);
      return TRUE;
  }
  
  void RefreshServices(int iRefresh)
  {
      int prev = _currentLitem;
      _currentLitem = 0;
      apxServiceBrowse(hService, _filterIname, _filterIimage,
                       _filterXname, _filterXimage, WM_USER+1+iRefresh,
                       ServiceCallback, NULL);
      ListView_SortItemsEx(hWndList, CompareFunc, NULL);
      if (prev > _currentLitem) {
          DestroyListView();
          apxServiceBrowse(hService, _filterIname, _filterIimage,
                           _filterXname, _filterXimage, WM_USER+1,
                           ServiceCallback, NULL);
          ListView_SortItemsEx(hWndList, CompareFunc, NULL);
      }
      if ((lvHitItem = ListView_GetSelectionMark(hWndList)) >= 0) {
  #if 0
          /* Ensure that the selected is visible */
          ListView_EnsureVisible(hWndList,lvHitItem, FALSE);
  #endif
          PostMessage(hWndList, WM_USER_LREFRESH, 0, 0);
      }
  }
  
  void RestoreRefreshTimer()
  {
      if (_currentTimer == IDMV_UFAST)
          SetTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH, UPD_FAST, NULL); 
      else if (_currentTimer == IDMV_USLOW)
          SetTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH, UPD_SLOW, NULL); 
      else
          KillTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH);
  }
  
  /* wParam progress dialog handle
   */
  static BOOL __startServiceCallback(APXHANDLE hObject, UINT uMsg,
                                     WPARAM wParam, LPARAM lParam)
  {
      HWND hDlg = (HWND)hObject;
      APXHANDLE hSrv;
      switch (uMsg) {
          case WM_USER+1:
              hDlg = (HWND)lParam;
              hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
              if (!hSrv) {
                  EndDialog(hDlg, IDOK);
                  PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                              MAKEWPARAM(IDMS_REFRESH, 0), 0);
                  return FALSE;
              }
              if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
                  apxCloseHandle(hSrv);
                  EndDialog(hDlg, IDOK);
                  PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                              MAKEWPARAM(IDMS_REFRESH, 0), 0);
                  return FALSE;
              }
              if (apxServiceControl(hSrv, SERVICE_CONTROL_CONTINUE, WM_USER+2,
                                    __startServiceCallback, hDlg)) {
                  _currentEntry->stServiceStatus.dwCurrentState = SERVICE_RUNNING;
                  _currentEntry->stStatusProcess.dwCurrentState = SERVICE_RUNNING;
                                  
              }
              apxCloseHandle(hSrv);
              EndDialog(hDlg, IDOK);
              PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                          MAKEWPARAM(IDMS_REFRESH, 0), 0);
          break;
          case WM_USER+2:
              SendMessage(hDlg, WM_USER+1, 0, 0);
              Sleep(500);
              break;
      }
      return TRUE;
  }
  
  static BOOL __stopServiceCallback(APXHANDLE hObject, UINT uMsg,
                                     WPARAM wParam, LPARAM lParam)
  {
      HWND hDlg = (HWND)hObject;
      APXHANDLE hSrv;
      switch (uMsg) {
          case WM_USER+1:
              hDlg = (HWND)lParam;
              hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
              if (!hSrv)
                  return FALSE;
              if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
                  apxCloseHandle(hSrv);
                  return FALSE;
              }
              if (apxServiceControl(hSrv, SERVICE_CONTROL_STOP, WM_USER+2,
                                    __stopServiceCallback, hDlg)) {
              }
              apxCloseHandle(hSrv);
              EndDialog(hDlg, IDOK);
              PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                          MAKEWPARAM(IDMS_REFRESH, 0), 0);
          break;
          case WM_USER+2:
              if (wParam == 4)
                  AplCopyMemory(&_currentEntry->stServiceStatus,
                                (LPVOID)lParam, sizeof(SERVICE_STATUS));
              SendMessage(hDlg, WM_USER+1, 0, 0);
              Sleep(100);
              break;
      }
      return TRUE;
  }
  
  static BOOL __restartServiceCallback(APXHANDLE hObject, UINT uMsg,
                                       WPARAM wParam, LPARAM lParam)
  {
      HWND hDlg = (HWND)hObject;
      APXHANDLE hSrv;
      switch (uMsg) {
          case WM_USER+1:
              hDlg = (HWND)lParam;
              hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
              if (!hSrv)
                  return FALSE;
              if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
                  apxCloseHandle(hSrv);
                  return FALSE;
              }
              /* TODO: use 128 as controll code */
              if (apxServiceControl(hSrv, 128, WM_USER+2,
                                    __restartServiceCallback, hDlg)) {
                                  
              }
              apxCloseHandle(hSrv);
              EndDialog(hDlg, IDOK);
              PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                          MAKEWPARAM(IDMS_REFRESH, 0), 0);
          break;
          case WM_USER+2:
              if (wParam == 4)
                  AplCopyMemory(&_currentEntry->stServiceStatus,
                                (LPVOID)lParam, sizeof(SERVICE_STATUS));
  
              SendMessage(hDlg, WM_USER+1, 0, 0);
              Sleep(100);
              break;
      }
      return TRUE;
  }
  
  static BOOL __pauseServiceCallback(APXHANDLE hObject, UINT uMsg,
                                     WPARAM wParam, LPARAM lParam)
  {
      HWND hDlg = (HWND)hObject;
      APXHANDLE hSrv;
      switch (uMsg) {
          case WM_USER+1:
              hDlg = (HWND)lParam;
              hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
              if (!hSrv)
                  return FALSE;
              if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
                  apxCloseHandle(hSrv);
                  return FALSE;
              }
              if (apxServiceControl(hSrv, SERVICE_CONTROL_PAUSE, WM_USER+2,
                                    __pauseServiceCallback, hDlg)) {
              }
              apxCloseHandle(hSrv);
              EndDialog(hDlg, IDOK);
              PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                          MAKEWPARAM(IDMS_REFRESH, 0), 0);
          break;
          case WM_USER+2:
              if (wParam == 4)
                  AplCopyMemory(&_currentEntry->stServiceStatus,
                               (LPVOID)lParam, sizeof(SERVICE_STATUS));
              SendMessage(hDlg, WM_USER+1, 0, 0);
              Sleep(100);
              break;
      }
      return TRUE;
  }
  
  LRESULT CALLBACK ListViewMainSubclass(HWND hWnd, UINT uMsg, WPARAM wParam,
                                        LPARAM lParam)
  {
      static POINTS  mouseClick;
  
      HMENU         hMenu = NULL;
      HMENU         hLoad = NULL;
      HMENU         hMain = NULL;
      switch (uMsg) {
          case WM_LBUTTONDOWN:
          case WM_RBUTTONDOWN:
          case WM_LBUTTONDBLCLK:
              mouseClick = MAKEPOINTS(lParam);
              lvLastHit.pt.x = mouseClick.x;
              lvLastHit.pt.y = mouseClick.y;
          case WM_USER_LREFRESH:
              lvHitItem = ListView_HitTest(hWndList, &lvLastHit);
              _currentEntry = NULL;
              hMain = GetMenu(_gui_store->hMainWnd);
              CallWindowProc(ListViewWinMain, hWnd, uMsg, wParam, lParam);
              EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_GRAYED);
              EnableMenuItem(hMain, IDMS_STOP, MF_BYCOMMAND | MF_GRAYED);
              EnableMenuItem(hMain, IDMS_PAUSE, MF_BYCOMMAND | MF_GRAYED);
              EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_GRAYED);
              EnableMenuItem(hMain, IDAM_DELETE, MF_BYCOMMAND | MF_GRAYED);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, FALSE);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_STOP, FALSE);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PAUSE, FALSE);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, FALSE);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PROPERTIES, FALSE);
              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDAM_DELETE, FALSE);
              EnableMenuItem(hMain, IDMS_PROPERTIES, MF_BYCOMMAND | MF_GRAYED);
  
              if (lvHitItem >= 0) {
                  LV_ITEM lvI;
                  lvI.mask = LVIF_PARAM;
                  lvI.iItem  = lvHitItem;
                  lvI.lParam = 0;
                  ListView_GetItem(hWndList, &lvI);
                  if (lvI.lParam) {
                      _currentEntry = (LPAPXSERVENTRY)lvI.lParam;
                      SendMessageW(hWndStatus, WM_SETTEXT, 0, (LPARAM)_currentEntry->szServiceDescription);
                      if (uMsg == WM_RBUTTONDOWN) {
                          hLoad = LoadMenu(_gui_store->hInstance,
                                           MAKEINTRESOURCE(IDM_POPUPMENU));
  
                          hMenu = GetSubMenu(hLoad, 0);
                      }
                      switch (_currentEntry->stServiceStatus.dwCurrentState) {
                          case SERVICE_RUNNING:
                              if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP) {
                                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_STOP, TRUE);
                                  EnableMenuItem(hMain, IDMS_STOP, MF_BYCOMMAND | MF_ENABLED);
                                  if (hMenu)
                                      EnableMenuItem(hMenu, IDMS_STOP, MF_BYCOMMAND | MF_ENABLED);
                              }
                              if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) {
                                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PAUSE, TRUE);
                                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, TRUE);
                                  EnableMenuItem(hMain, IDMS_PAUSE, MF_BYCOMMAND | MF_ENABLED);
                                  EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
                                  if (hMenu) {
                                      EnableMenuItem(hMenu, IDMS_PAUSE, MF_BYCOMMAND | MF_ENABLED);
                                      EnableMenuItem(hMenu, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
                                  }
                              }                            
                          break;
                          case SERVICE_PAUSED:
                              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, TRUE);
                              SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, TRUE);
                              EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
                              EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
                              if (hMenu) {
                                  EnableMenuItem(hMenu, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
                                  EnableMenuItem(hMenu, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
                              }
                          break;
                          case SERVICE_STOPPED:
                              if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
                                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, TRUE);
                                  EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
                                  if (hMenu)
                                      EnableMenuItem(hMenu, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
                              }
                          break;
                          default:
  
                          break;
                      }
                  }
                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PROPERTIES, TRUE);
                  EnableMenuItem(hMain, IDMS_PROPERTIES, MF_BYCOMMAND | MF_ENABLED);
                  SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDAM_DELETE, TRUE);
                  EnableMenuItem(hMain, IDAM_DELETE, MF_BYCOMMAND | MF_ENABLED);
                  SetMenuDefaultItem(GetSubMenu(hMain, 1), IDMS_PROPERTIES, FALSE);
  
                  if (hMenu) {
                      POINT pt; 
                      EnableMenuItem(hMenu, IDMS_PROPERTIES, MF_BYCOMMAND | MF_ENABLED);
                      SetMenuDefaultItem(hMenu, IDMS_PROPERTIES, FALSE);
  
                      GetCursorPos(&pt); 
                      TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
                          pt.x, pt.y, 0, _gui_store->hMainWnd, NULL);
                      DestroyMenu(hLoad);
                      hMenu = NULL;
                      hLoad = NULL;
                  }
                  /* Post the Properties message to main window */
                  if (uMsg == WM_LBUTTONDBLCLK) {
                      PostMessage(_gui_store->hMainWnd, WM_COMMAND, 
                                  MAKEWPARAM(IDMS_PROPERTIES, 0), 0);
                  }
              }
              else {
                  SetMenuDefaultItem(GetSubMenu(hMain, 1), -1, FALSE);
                  SendMessageW(hWndStatus, WM_SETTEXT, 0, (LPARAM)(L""));
              }
              return TRUE;
          break;
      }
      return CallWindowProc(ListViewWinMain, hWnd, uMsg, wParam, lParam);
  }
  
  LRESULT CALLBACK ListViewHeadSubclass(HWND hWnd, UINT uMsg, WPARAM wParam,
                                        LPARAM lParam)
  {
      DWORD     i, n = 0;
  
      switch (uMsg) {
          case WM_LBUTTONUP:
              CallWindowProc(ListViewWinHead, hWnd, uMsg, wParam, lParam);
              for (i = 0; i < NUMLVITEMS; i++) {
                  if (lvItems[i].iWidth) {
                      lvItems[i].iWidth = ListView_GetColumnWidth(hWndList, n++);
                  }
              }
              return TRUE;
          break;
  
      }
      return CallWindowProc(ListViewWinHead, hWnd, uMsg, wParam, lParam);
  }
  
  HWND CreateServiceList(HWND hWndParent)
  {
      HWND        hWndList;
      RECT        rc;
      LV_COLUMN   lvC;
      DWORD       i;
      HBITMAP     hStatBmp;
      HIMAGELIST  hStatImg;
      DWORD       dwStyle;
  
      dwStyle =   WS_TABSTOP | 
                  WS_CHILD | 
                  WS_VISIBLE |
                  LVS_SINGLESEL |
                  LVS_REPORT;
  
      GetWindowRect(hWndToolbar, &rc);
      _toolbarHeight = rc.bottom - rc.top;
      GetWindowRect(hWndStatus, &rc);
      _statbarHeight = rc.bottom - rc.top;
      /* Get the size and position of the parent window. */
      GetClientRect(hWndParent, &rc);
  
      /* Create the list view window */
      hWndList = CreateWindowEx(WS_EX_CLIENTEDGE,
                                WC_LISTVIEW, TEXT(""), 
                                dwStyle,
                                0, _toolbarHeight, 
                                rc.right - rc.left, 
                                rc.bottom - rc.top - _toolbarHeight - _statbarHeight,
                                hWndParent,
                                (HMENU)IDC_LISTVIEW,
                                _gui_store->hInstance, NULL);
      if (hWndList == NULL)
          return NULL;
      GetClientRect(hWndList, &rc);
      hStatImg = ImageList_Create(16, 16, ILC_COLOR4, 0, 16);
      hStatBmp = LoadImage(GetModuleHandleA(NULL), MAKEINTRESOURCE(IDB_SSTATUS),
                           IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
  
      ImageList_Add(hStatImg, hStatBmp, NULL);
      DeleteObject(hStatBmp);
  
      ListView_SetImageList(hWndList, hStatImg, LVSIL_SMALL);
      lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
      _listviewCols = 0;
      for (i = 0; i < NUMLVITEMS; i++) {
          lvC.iSubItem = i;
          lvC.cx       = lvItems[i].iWidth;
          lvC.pszText  = lvItems[i].szLabel;
          lvC.fmt      = lvItems[i].iFmt;
          if (lvItems[i].iWidth > 0) {
              ListView_InsertColumn(hWndList, i, &lvC ); 
              _listviewCols++;
          }
      }
  #ifdef LVS_EX_FULLROWSELECT
      ListView_SetExtendedListViewStyleEx(hWndList, 0,
                  LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
  #endif 
      hWndListHdr = ListView_GetHeader(hWndList);
      /* Sub-class */
      ListViewWinMain = (WNDPROC)((SIZE_T)SetWindowLong(hWndList, GWL_WNDPROC, 
                                                        (LONG)((SIZE_T)ListViewMainSubclass))); 
  
      ListViewWinHead = (WNDPROC)((SIZE_T)SetWindowLong(hWndListHdr, GWL_WNDPROC, 
                                                        (LONG)((SIZE_T)ListViewHeadSubclass))); 
  
  
      return hWndList;
  }
  
  static DWORD  _propertyChanged;
  /* Service property pages */
  void CALLBACK __propertyCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
  {
      switch(uMsg) {
          case PSCB_PRECREATE:       
             {
                  LPDLGTEMPLATE  lpTemplate = (LPDLGTEMPLATE)lParam;
                  if (!(lpTemplate->style & WS_SYSMENU))
                      lpTemplate->style |= WS_SYSMENU;
                  apxCenterWindow(hwndPropSheet, _gui_store->hMainWnd);
                  _propertyChanged = 0;
              }
          break;
          case PSCB_INITIALIZED:
          break;
  
      }
  }
  
  BOOL __generalPropertySave(HWND hDlg) 
  {
      APXHANDLE hSrv;
      WCHAR szN[256];
      WCHAR szD[256];
      DWORD dwStartType = SERVICE_NO_CHANGE;
      int i;
  
      if (!(TST_BIT_FLAG(_propertyChanged, 1)))
          return TRUE;
      CLR_BIT_FLAG(_propertyChanged, 1);
  
      if (!(hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE)))
          return FALSE;
      if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
          apxCloseHandle(hSrv);
          return FALSE;
      }
      GetDlgItemTextW(hDlg, IDC_PPSGDISP, szN, 255);
      GetDlgItemTextW(hDlg, IDC_PPSGDESC, szD, 1023);
      i = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST));
      if (i == 0)
          dwStartType = SERVICE_AUTO_START;
      else if (i == 1)
          dwStartType = SERVICE_DEMAND_START;
      else if (i == 2)
          dwStartType = SERVICE_DISABLED;
      apxServiceSetNames(hSrv, NULL, szN, szD, NULL, NULL);
      apxServiceSetOptions(hSrv, SERVICE_NO_CHANGE, dwStartType, SERVICE_NO_CHANGE);
  
      apxCloseHandle(hSrv);
      if (!(TST_BIT_FLAG(_propertyChanged, 2)))
          PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
  
      return TRUE;
  }
  
  BOOL __generalLogonSave(HWND hDlg) 
  {
      APXHANDLE hSrv;
      WCHAR szU[64];
      WCHAR szP[64];
      WCHAR szC[64];
      DWORD dwStartType = SERVICE_NO_CHANGE;
  
      if (!(TST_BIT_FLAG(_propertyChanged, 2)))
          return TRUE;
      CLR_BIT_FLAG(_propertyChanged, 2);
  
      if (!(hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE)))
          return FALSE;
      if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
          apxCloseHandle(hSrv);
          return FALSE;
      }
      GetDlgItemTextW(hDlg, IDC_PPSLUSER,  szU, 63);
      GetDlgItemTextW(hDlg, IDC_PPSLPASS,  szP, 63);
      GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
      
      if (lstrlenW(szU) && lstrcmpiW(szU, STAT_SYSTEM)) {
          if (szP[0] != L' ' &&  szC[0] != L' ' && !lstrcmpW(szP, szC))
              apxServiceSetNames(hSrv, NULL, NULL, NULL, szU, szP);
          else {
              MessageBoxW(hDlg, apxLoadResourceW(IDS_VALIDPASS, 0),
                          apxLoadResourceW(IDS_APPLICATION, 1),
                          MB_OK | MB_ICONSTOP);
              apxCloseHandle(hSrv);
              return FALSE;
          }
      }             
      else {
          if (IsDlgButtonChecked(hDlg, IDC_PPSLID) == BST_CHECKED)
              apxServiceSetOptions(hSrv,
                  _currentEntry->stServiceStatus.dwServiceType | SERVICE_INTERACTIVE_PROCESS,
                  SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
          else
              apxServiceSetOptions(hSrv,
                  _currentEntry->stServiceStatus.dwServiceType & ~SERVICE_INTERACTIVE_PROCESS,
                  SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
      }
      apxCloseHandle(hSrv);
      if (!(TST_BIT_FLAG(_propertyChanged, 1)))
          PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
      return TRUE;
  }
  
  void __generalPropertyRefresh(HWND hDlg)
  {
      Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), FALSE);
      Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), FALSE);
      Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), FALSE);
      Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), FALSE);
      switch (_currentEntry->stServiceStatus.dwCurrentState) {
          case SERVICE_RUNNING:
              if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP ||
                  _currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
                  Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), TRUE);
                  SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STARTED);
              }
              else
                  SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
              if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) {
                  Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), TRUE);
                  Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
              }
          break;
          case SERVICE_PAUSED:
              Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
              Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
              SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_PAUSED);
          break;
          case SERVICE_STOPPED:
              if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
                  Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
                  SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
              }
              else
                  SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STOPPED);
          break;
          default:
          break;
      }
  }
  
  LRESULT CALLBACK __generalProperty(HWND hDlg,
                                     UINT uMessage,
                                     WPARAM wParam,
                                     LPARAM lParam)
  {
      LPPSHNOTIFY lpShn;
      WCHAR       szBuf[1024]; 
  
      switch (uMessage) { 
          case WM_INITDIALOG: 
              {
                  PROPSHEETPAGE *lpPage = (PROPSHEETPAGE *)lParam;
                  LPAPXSERVENTRY lpService;
                  BOOL           bLocalSystem = TRUE;
                  
                  lpService = ( LPAPXSERVENTRY)lpPage->lParam;
                  SendMessage(GetDlgItem(hDlg, IDC_PPSGDISP), EM_LIMITTEXT, 255, 0);
                  SendMessage(GetDlgItem(hDlg, IDC_PPSGDESC), EM_LIMITTEXT, 1023, 0);
  
                  ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_AUTO);
                  ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_MANUAL);
                  ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_DISABLED);
                  if (_currentEntry->lpConfig->dwStartType == SERVICE_AUTO_START)
                      ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 0);
                  else if (_currentEntry->lpConfig->dwStartType == SERVICE_DEMAND_START)
                      ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 1);
                  else if (_currentEntry->lpConfig->dwStartType == SERVICE_DISABLED)
                      ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 2);
  
                  SetDlgItemTextW(hDlg, IDC_PPSGNAME, _currentEntry->szServiceName);
                  SetDlgItemTextW(hDlg, IDC_PPSGDISP, _currentEntry->lpConfig->lpDisplayName);
                  SetDlgItemTextW(hDlg, IDC_PPSGDESC, _currentEntry->szServiceDescription);
                  SetDlgItemTextW(hDlg, IDC_PPSGDEXE, _currentEntry->lpConfig->lpBinaryPathName);
                  __generalPropertyRefresh(hDlg);
              }
          break;
          case WM_COMMAND:
              switch (LOWORD(wParam)) {
                  case IDC_PPSGCMBST:
                      if (HIWORD(wParam) == CBN_SELCHANGE) {
                          PropSheet_Changed(GetParent(hDlg), hDlg); 
                          SET_BIT_FLAG(_propertyChanged, 1);
                      }
                  break;
                  case IDC_PPSGDISP:
                      if (HIWORD(wParam) == EN_CHANGE) {
                          GetDlgItemTextW(hDlg, IDC_PPSGDISP, szBuf, 255);
                          if (!lstrcmpW(szBuf, _currentEntry->lpConfig->lpDisplayName)) {
                              PropSheet_UnChanged(GetParent(hDlg), hDlg);
                              CLR_BIT_FLAG(_propertyChanged, 1);
                          }
                          else {
                              PropSheet_Changed(GetParent(hDlg), hDlg);
                              SET_BIT_FLAG(_propertyChanged, 1);
                          }
                      }
                  break;
                  case IDC_PPSGDESC:
                      if (HIWORD(wParam) == EN_CHANGE) {
                          GetDlgItemTextW(hDlg, IDC_PPSGDESC, szBuf, 1023);
                          if (!lstrcmpW(szBuf, _currentEntry->szServiceDescription)) {
                              PropSheet_UnChanged(GetParent(hDlg), hDlg);
                              CLR_BIT_FLAG(_propertyChanged, 1);
                          }
                          else {
                              PropSheet_Changed(GetParent(hDlg), hDlg);
                              SET_BIT_FLAG(_propertyChanged, 1);
                          }
                      }
                  break;
                  case IDC_PPSGSTART:
                      apxProgressBox(hDlg, apxLoadResource(IDS_HSSTART, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __startServiceCallback, NULL);
                      __generalPropertyRefresh(hDlg);
                  break;
                  case IDC_PPSGSTOP:
                      apxProgressBox(hDlg, apxLoadResource(IDS_HSSTOP, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __stopServiceCallback, NULL);
                      __generalPropertyRefresh(hDlg);
                  break;
                  case IDC_PPSGPAUSE:
                      apxProgressBox(hDlg, apxLoadResource(IDS_HSPAUSE, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __pauseServiceCallback, NULL);
                      __generalPropertyRefresh(hDlg);
                  break;
                  case IDC_PPSGRESTART:
                      apxProgressBox(hDlg, apxLoadResource(IDS_HSRESTART, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __restartServiceCallback, NULL);
                      __generalPropertyRefresh(hDlg);
                  break;
              }
          break;
          case WM_NOTIFY:           
              lpShn = (LPPSHNOTIFY )lParam;
              switch (lpShn->hdr.code) {
                  case PSN_APPLY:   /* sent when OK or Apply button pressed */ 
                      if (__generalPropertySave(hDlg)) {
                          PropSheet_UnChanged(GetParent(hDlg), hDlg);
                      }
                      else {
                          SET_BIT_FLAG(_propertyChanged, 1);
                          SetWindowLong(hDlg, DWL_MSGRESULT,
                                        PSNRET_INVALID_NOCHANGEPAGE);
                          return TRUE;                        
                      }
  
                  break;
                  default:
                  break;
              }
          break;
          default:
          break;
      }
   
      return FALSE;
  }
  
  LRESULT CALLBACK __logonProperty(HWND hDlg,
                                   UINT uMessage,
                                   WPARAM wParam,
                                   LPARAM lParam)
  {
      LPPSHNOTIFY lpShn;
      WCHAR       szBuf[1024]; 
      switch (uMessage) { 
          case WM_INITDIALOG:
              {
                  BOOL           bAccount = FALSE;
                  
                  SendMessage(GetDlgItem(hDlg, IDC_PPSLUSER), EM_LIMITTEXT, 63, 0);
                  SendMessage(GetDlgItem(hDlg, IDC_PPSLPASS), EM_LIMITTEXT, 63, 0);
                  SendMessage(GetDlgItem(hDlg, IDC_PPSLCPASS), EM_LIMITTEXT, 63, 0);
                  if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
                      bAccount = TRUE;
                      CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLUA);
                      SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
                      SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
                      SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
                  }
                  else {
                      CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLLS);
                      if (_currentEntry->lpConfig->dwServiceType & 
                          SERVICE_INTERACTIVE_PROCESS)
                          CheckDlgButton(hDlg, IDC_PPSLID, BST_CHECKED);
                  }
                  EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), !bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), bAccount);
                  EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), bAccount);
              }
          break;
          case WM_COMMAND:
              switch (LOWORD(wParam)) {
                  case IDC_PPSLLS:
                      SetDlgItemTextW(hDlg, IDC_PPSLUSER, L"");
                      SetDlgItemTextW(hDlg, IDC_PPSLPASS, L"");
                      SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L"");
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE);
                      CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);                     
                      if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
                          PropSheet_Changed(GetParent(hDlg), hDlg); 
                          SET_BIT_FLAG(_propertyChanged, 2);
                      }
                      else {
                          PropSheet_UnChanged(GetParent(hDlg), hDlg); 
                          CLR_BIT_FLAG(_propertyChanged, 2);
                      }
                      break;
                  case IDC_PPSLUA:
                      SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
                      SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
                      SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), FALSE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), TRUE);
                      EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), TRUE);
                      CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);                     
                      if (lstrcmpW(_currentEntry->szObjectName, STAT_SYSTEM)) {
                          PropSheet_Changed(GetParent(hDlg), hDlg); 
                          SET_BIT_FLAG(_propertyChanged, 2);
                      }
                      else {
                          PropSheet_UnChanged(GetParent(hDlg), hDlg); 
                          CLR_BIT_FLAG(_propertyChanged, 2);
                      }
                      break;
                  case IDC_PPSLID:
                      PropSheet_Changed(GetParent(hDlg), hDlg); 
                      SET_BIT_FLAG(_propertyChanged, 2);
                  break;
                  case IDC_PPSLUSER:
                      if (HIWORD(wParam) == EN_CHANGE) {
                          GetDlgItemTextW(hDlg, IDC_PPSLUSER, szBuf, 63);
                          if (!lstrcmpiW(szBuf, _currentEntry->szObjectName)) {
                              PropSheet_UnChanged(GetParent(hDlg), hDlg);
                              CLR_BIT_FLAG(_propertyChanged, 2);
                          }
                          else {
                              PropSheet_Changed(GetParent(hDlg), hDlg);
                              SET_BIT_FLAG(_propertyChanged, 2);
                          }
                      }
                  break;
                  case IDC_PPSLPASS:
                  case IDC_PPSLCPASS:
                      if (HIWORD(wParam) == EN_CHANGE) {
                          WCHAR szP[64];
                          WCHAR szC[64];
                          GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, 63);
                          GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
                          /* check for valid password match */
                          if (szP[0] == L' ' &&  szC[0] == L' ') {
                              PropSheet_UnChanged(GetParent(hDlg), hDlg);
                              CLR_BIT_FLAG(_propertyChanged, 2);
                          }
                          else if (!lstrcmpW(szP, szC)) {
                              PropSheet_Changed(GetParent(hDlg), hDlg);
                              SET_BIT_FLAG(_propertyChanged, 2);
                          }
                      }
                  break;
                  case IDC_PPSLBROWSE:
                      {
                          WCHAR szUser[SIZ_RESLEN];
                          if (apxDlgSelectUser(hDlg, szUser))
                              SetDlgItemTextW(hDlg, IDC_PPSLUSER, szUser);
                      }
                  break;
              }
          break;
          case WM_NOTIFY:
              lpShn = (LPPSHNOTIFY )lParam;
              switch (lpShn->hdr.code) {
                  case PSN_APPLY:   /* sent when OK or Apply button pressed */ 
                      if (__generalLogonSave(hDlg))
                          PropSheet_UnChanged(GetParent(hDlg), hDlg); 
                      else {
                          SET_BIT_FLAG(_propertyChanged, 2);
                          SetWindowLong(hDlg, DWL_MSGRESULT,
                                        PSNRET_INVALID_NOCHANGEPAGE);
                          return TRUE;                        
                      }
  
                  break;
              }
          break;
  
          default:
          break;
      }
      return FALSE;
  }
  
  void __initPpage(PROPSHEETPAGEW *lpPage, INT iDlg, INT iTitle, DLGPROC pfnDlgProc)
  {
      lpPage->dwSize      = sizeof(PROPSHEETPAGE);
      lpPage->dwFlags     = PSP_USETITLE;
      lpPage->hInstance   = _gui_store->hInstance;
      lpPage->pszTemplate = MAKEINTRESOURCEW(iDlg);
      lpPage->pszIcon     = NULL;
      lpPage->pfnDlgProc  = pfnDlgProc;
      lpPage->pszTitle    = MAKEINTRESOURCEW(iTitle);
      lpPage->lParam      = 0;
  }
  
  INT_PTR ShowServiceProperties(HWND hWnd)
  {
      PROPSHEETPAGEW   psP[5];
      PROPSHEETHEADERW psH; 
      WCHAR           szT[1024] = {0};
  
      __initPpage(&psP[0], IDD_PROPPAGE_SGENERAL, IDS_PPGENERAL, 
                  __generalProperty);
      __initPpage(&psP[1], IDD_PROPPAGE_LOGON, IDS_PPLOGON, 
                  __logonProperty);
  
      if (_currentEntry && _currentEntry->lpConfig)
          lstrcpyW(szT, _currentEntry->lpConfig->lpDisplayName);
      else
          return (INT_PTR)0;
      lstrcatW(szT, L" Service Properties");
  
      psH.dwSize           = sizeof(PROPSHEETHEADER);
      psH.dwFlags          = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK | PSH_NOCONTEXTHELP;
      psH.hwndParent       = hWnd;
      psH.hInstance        = _gui_store->hInstance;
      psH.pszIcon          = MAKEINTRESOURCEW(IDI_MAINICON);
      psH.pszCaption       = szT;
      psH.nPages           = 2;
      psH.ppsp             = (LPCPROPSHEETPAGEW) &psP;
      psH.pfnCallback      = (PFNPROPSHEETCALLBACK)__propertyCallback;
      psH.nStartPage       = 0;   
  
      return PropertySheetW(&psH);
  }
  
  static LRESULT CALLBACK __filtersDlgProc(HWND hDlg, UINT uMsg,
                                           WPARAM wParam, LPARAM lParam)
  {
  
      switch (uMsg) {
          case WM_INITDIALOG:
              apxCenterWindow(hDlg, _gui_store->hMainWnd);
              if (_filterIname)
                  SetDlgItemTextW(hDlg, IDC_FINAME, _filterIname);
              if (_filterIimage)
                  SetDlgItemTextW(hDlg, IDC_FISIMG, _filterIimage);
              if (_filterXname)
                  SetDlgItemTextW(hDlg, IDC_FXNAME, _filterXname);
              if (_filterXimage)
                  SetDlgItemTextW(hDlg, IDC_FXSIMG, _filterXimage);
              return TRUE;
          break;
          case WM_COMMAND:
              switch (LOWORD(wParam)) {
                  case IDOK:
                      {
                          apxFree(_filterIname);
                          _filterIname = apxGetDlgTextW(hPool, hDlg, IDC_FINAME);
                          apxFree(_filterXname);
                          _filterXname = apxGetDlgTextW(hPool, hDlg, IDC_FXNAME);
                          apxFree(_filterIimage);
                          _filterIimage = apxGetDlgTextW(hPool, hDlg, IDC_FISIMG);
                          apxFree(_filterXimage);
                          _filterXimage = apxGetDlgTextW(hPool, hDlg, IDC_FXSIMG);
                          PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                                      MAKEWPARAM(IDMS_REFRESH, 0), 0);
                      }
                  case IDCANCEL:
                      EndDialog(hDlg, LOWORD(wParam));
                  return TRUE;
              }
          break;
      }
      return FALSE;
  } 
  
  void EditServiceFilters(HWND hWnd)
  {
  
     DialogBox(_gui_store->hInstance,
                MAKEINTRESOURCE(IDD_FILTER),
                hWnd,
                (DLGPROC)__filtersDlgProc);
  
  }
  
  static LRESULT CALLBACK __selectColsDlgProc(HWND hDlg, UINT uMsg,
                                              WPARAM wParam, LPARAM lParam)
  {
  
      switch (uMsg) {
          case WM_INITDIALOG:
              apxCenterWindow(hDlg, _gui_store->hMainWnd);
              CheckDlgButton(hDlg, IDC_CCOL1, lvItems[1].iWidth != 0);
              CheckDlgButton(hDlg, IDC_CCOL2, lvItems[2].iWidth != 0);
              CheckDlgButton(hDlg, IDC_CCOL3, lvItems[3].iWidth != 0);
              CheckDlgButton(hDlg, IDC_CCOL4, lvItems[4].iWidth != 0);
              CheckDlgButton(hDlg, IDC_CCOL5, lvItems[5].iWidth != 0);
  
              return TRUE;
          break;
          case WM_COMMAND:
              switch (LOWORD(wParam)) {
                  case IDOK:
                      if (IsDlgButtonChecked(hDlg, IDC_CCOL1) != BST_CHECKED)
                          lvItems[1].iWidth = 0;
                      else if (lvItems[1].iWidth == 0)
                          lvItems[1].iWidth = lvItems[1].iDefault;
                      if (IsDlgButtonChecked(hDlg, IDC_CCOL2) != BST_CHECKED)
                          lvItems[2].iWidth = 0;
                      else if (lvItems[2].iWidth == 0)
                          lvItems[2].iWidth = lvItems[2].iDefault;
                      if (IsDlgButtonChecked(hDlg, IDC_CCOL3) != BST_CHECKED)
                          lvItems[3].iWidth = 0;
                      else if (lvItems[3].iWidth == 0)
                          lvItems[3].iWidth = lvItems[3].iDefault;
                      if (IsDlgButtonChecked(hDlg, IDC_CCOL4) != BST_CHECKED)
                          lvItems[4].iWidth = 0;
                      else if (lvItems[4].iWidth == 0)
                          lvItems[4].iWidth = lvItems[4].iDefault;
                      if (IsDlgButtonChecked(hDlg, IDC_CCOL5) != BST_CHECKED)
                          lvItems[5].iWidth = 0;
                      else if (lvItems[5].iWidth == 0)
                          lvItems[5].iWidth = lvItems[5].iDefault;
                      CloseWindow(hWndList);
                      hWndList = CreateServiceList(_gui_store->hMainWnd); 
  
                      PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                                  MAKEWPARAM(IDMS_REFRESH, 0), 0);
  
                  case IDCANCEL:
                      EndDialog(hDlg, LOWORD(wParam));
                  return TRUE;
              }
          break;
      }
      return FALSE;
  } 
  
  void SelectDisplayColumns(HWND hWnd)
  {
  
     DialogBox(_gui_store->hInstance,
                MAKEINTRESOURCE(IDD_SELCOL),
                hWnd,
                (DLGPROC)__selectColsDlgProc);
  
  }
  
  LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg,
                               WPARAM wParam, LPARAM lParam) 
  {
      RECT rcP;
      LPNMHDR     lpNmHdr; 
  
      switch (uMsg) {
          case WM_CREATE:
  
              hWndToolbar = CreateToolbarEx(hWnd, 
                                            WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,  
                                            IDC_TOOLBAR, NUMTOOLBUTTONS,
                                            _gui_store->hInstance, IDB_TOOLBAR,
                                            (LPCTBBUTTON)&tbButtons,
                                            NUMTBBUTTONS, 16,16,16,16, sizeof(TBBUTTON)); 
              hWndStatus = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
                                              | WS_CHILD | WS_VISIBLE,
                                              TEXT(""), hWnd, IDC_STATBAR); 
  
              hWndList = CreateServiceList(hWnd); 
              RefreshServices(0);
              CheckMenuRadioItem(GetMenu(hWnd), IDMV_UFAST, IDMV_UPAUSED,
                                 _currentTimer, MF_BYCOMMAND);
              RestoreRefreshTimer();
              return FALSE;
          break;
          case WM_SETFOCUS:
              SetFocus(hWndList);
              return FALSE;
          break;
          case WM_SIZE:
              MoveWindow(hWndToolbar, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
              MoveWindow(hWndList, 0, _toolbarHeight, LOWORD(lParam),
                         HIWORD(lParam) -  _toolbarHeight - _statbarHeight, TRUE);
              MoveWindow(hWndStatus, 0, HIWORD(lParam) - _statbarHeight, 
                         LOWORD(lParam), HIWORD(lParam), TRUE);
              GetWindowRect(hWnd, &rcP);
              _gui_store->stState.rcPosition.top    = rcP.top;
              _gui_store->stState.rcPosition.left   = rcP.left;
              _gui_store->stState.rcPosition.right  = ABS(rcP.right - rcP.left);
              _gui_store->stState.rcPosition.bottom = ABS(rcP.bottom - rcP.top);
              if (wParam == SIZE_MAXIMIZED)
                  _gui_store->stState.dwShow = SW_SHOWMAXIMIZED;
              else
                  _gui_store->stState.dwShow = SW_SHOW;
  
              return FALSE;
          break;   
          case WM_TIMER: 
              if (wParam == WM_TIMER_REFRESH) {
                  KillTimer(hWnd, WM_TIMER_REFRESH);
                  RefreshServices(1);
                  RestoreRefreshTimer();
              }
          break;
          case WM_NOTIFY: 
              lpNmHdr = (NMHDR FAR *)lParam;
              switch (lpNmHdr->code) { 
                  case TTN_GETDISPINFO: 
                      { 
                          LPTOOLTIPTEXT lpttt; 
                          lpttt = (LPTOOLTIPTEXT)lParam; 
                          lpttt->hinst = _gui_store->hInstance; 
                          /* Specify the resource identifier of the descriptive 
                           * text for the given button. 
                           */
                          lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom);
                      }
                  break; 
                  case LVN_COLUMNCLICK :
                      {
                          LPNMLISTVIEW pLvi = (LPNMLISTVIEW)lParam;
                          /* Find the real column */
                          if (pLvi->iSubItem >= 0) {
                              INT i, x = 0;
                              for (i = 0; i < NUMLVITEMS; i++) {
                                  if (lvItems[i].iWidth && x < pLvi->iSubItem)
                                      ++x;
                                  else
                                      break;
                              }
                              if (lvItems[x].bSortable) {
                                  if (_sortColumn == x)
                                      _sortOrder *= (-1);
                                  else {
                                      _sortColumn = x;
                                      _sortOrder  = 1;
                                  }
                                  ListView_SortItemsEx(hWndList, CompareFunc, NULL);
                                  if ((lvHitItem = ListView_GetSelectionMark(hWndList)) >= 0) {
                                      ListView_EnsureVisible(hWndList,lvHitItem, FALSE);
                                  }
                              }
                          }
                      }
                  break;
                  /* 
                   * Process other notifications here. 
                   */ 
                  default: 
                  break; 
              } 
          break;
          case WM_COMMAND:
              switch(LOWORD(wParam)) {
                  case IDMS_REFRESH:
                      KillTimer(hWnd, WM_TIMER_REFRESH);
                      RefreshServices(1);
                      RestoreRefreshTimer();
                  break;
                  case IDAM_TRY:
                      apxManageTryIconA(hWnd, NIM_ADD, NULL,
                                        apxLoadResourceA(IDS_APPLICATION, 0),
                                        NULL);
  
                      KillTimer(hWnd, WM_TIMER_REFRESH);
                      ShowWindow(hWnd, SW_HIDE);
                  break;
                  case IDAM_EXIT:
                      SendMessage(hWnd, WM_CLOSE, 0, 0);
                  break;
                  case IDMH_ABOUT:
                      apxAboutBox(hWnd);
                  break;
                  case IDMS_START:
                      apxProgressBox(hWnd, apxLoadResource(IDS_HSSTART, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __startServiceCallback, NULL);
                  break;
                  case IDMS_STOP:
                      apxProgressBox(hWnd, apxLoadResource(IDS_HSSTOP, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __stopServiceCallback, NULL);
                  break;
                  case IDMS_PAUSE:
                      apxProgressBox(hWnd, apxLoadResource(IDS_HSPAUSE, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __pauseServiceCallback, NULL);
                  break;
                  case IDMS_RESTART:
                      apxProgressBox(hWnd, apxLoadResource(IDS_HSRESTART, 0),
                                     _currentEntry->lpConfig->lpDisplayName,
                                     __restartServiceCallback, NULL);
                  break;
                  case IDMS_PROPERTIES:
                      KillTimer(hWnd, WM_TIMER_REFRESH);
                      ShowServiceProperties(hWnd);
                      RestoreRefreshTimer();
                  break;
                  case IDMV_UFAST:
                  case IDMV_USLOW:
                  case IDMV_UPAUSED:
                      _currentTimer = LOWORD(wParam);
                      CheckMenuRadioItem(GetMenu(hWnd), IDMV_UFAST, IDMV_UPAUSED,
                                         _currentTimer, MF_BYCOMMAND);
                      RestoreRefreshTimer();
                  break;
                  case IDAM_DELETE:
                      {
                          TCHAR szT[1024+128];
  #ifndef _UNICODE
                          CHAR dName[1024];
                          WideToAscii(_currentEntry->lpConfig->lpDisplayName, dName);
  #endif
                          if (!_currentEntry || !_currentEntry->lpConfig)
                              return FALSE;
  
                          wsprintf(szT, apxLoadResource(IDS_DELSERVICET, 0),
  #ifdef _UNICODE
                                   _currentEntry->lpConfig->lpDisplayName);
  #else
                                   dName);
  #endif
                          KillTimer(hWnd, WM_TIMER_REFRESH);
                          if (apxYesNoMessage(apxLoadResource(IDS_DELSERVICEC, 0),
                                              szT, TRUE)) {
                              APXHANDLE hSrv;
                              if ((hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE))) {
                                  if (apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
                                      apxServiceDelete(hSrv);
                                      RefreshServices(1);
                                  }
                                  apxCloseHandle(hSrv);
                              }
                          }
                          RestoreRefreshTimer();
                      }
                  break;
                  case IDMV_FILTER:
                      EditServiceFilters(hWnd);
                  break;
                  case IDMV_SELECTCOLUMNS:
                      SelectDisplayColumns(hWnd);
                  break;
                  case IDAM_SAVE:
                      if (_exportFilename) {
                          ExportListView(_exportFilename, _exportIndex);
                          return FALSE;
                      }
                  case IDAM_SAVEAS:
                      if (_exportFilename)
                          apxFree(_exportFilename);
                      _exportFilename = apxGetFileNameA(hWnd, EXPORT_TITLE,
                                                        EXPORT_EXTFILT,
                                                        ".csv", NULL, FALSE,
                                                        &_exportIndex);
                      if (_exportFilename)
                          ExportListView(_exportFilename, _exportIndex);
                  break;
                  case IDAM_NEW:
                      /* TODO: New service wizard */
                      MessageBox(hWnd, apxLoadResource(IDS_NOTIMPLEMENTED, 0),
                                 apxLoadResource(IDS_APPLICATION, 1),
                                 MB_OK | MB_ICONINFORMATION);
                  break;
                  default:
                      return DefWindowProc(hWnd, uMsg, wParam, lParam); 
                  break;
              }
          break;
          case WM_TRAYMESSAGE:
              switch(lParam) {
                  case WM_LBUTTONDBLCLK:
                      ShowWindow(hWnd, SW_SHOW);
                      apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
                      RestoreRefreshTimer();
                  break;
              }
          break;
          case WM_MOUSEWHEEL:
              {
                  int nScroll;
                  if ((SHORT)HIWORD(wParam) < 0)
                      nScroll = _gui_store->nWhellScroll;
                  else
                      nScroll = _gui_store->nWhellScroll * (-1);
                  ListView_Scroll(hWndList, 0, nScroll * 16);
              }
          break;
          case WM_QUIT:
              OutputDebugString(TEXT("WM_QUIT"));
              return DefWindowProc(hWnd, uMsg, wParam, lParam); 
          break;
          case WM_DESTROY:
              DestroyListView();
              apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
              OutputDebugString(TEXT("WM_DESTROY"));
              PostQuitMessage(0);
              return FALSE;
          break;
          default:
              return DefWindowProc(hWnd, uMsg, wParam, lParam); 
          break;
      }
  
      return FALSE; 
  }
  
  /* Browse service callback */
  BOOL ServiceCallback(APXHANDLE hObject, UINT uMsg,
                       WPARAM wParam, LPARAM lParam)
  {
      LPAPXSERVENTRY  lpEnt = (LPAPXSERVENTRY)wParam;
      LV_ITEM         lvI;
      LV_ITEM         lvO;
      INT             row = 0x7FFFFFFF;
      WCHAR           szPid[16];
      LPAPXSERVENTRY  lpEntry = NULL;
      int             i;
  
      AplZeroMemory(&lvI, sizeof(LV_ITEM)); 
      lvI.mask        = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
      lvI.iItem       = 0x7FFFFFFF;
      switch (lpEnt->stServiceStatus.dwCurrentState) {
          case SERVICE_RUNNING:
              lvI.iImage      = 0;
              lvI.pszText     = STAT_STARTED;
          break;
          case SERVICE_STOPPED:
              lvI.iImage      = 1;
              lvI.pszText     = STAT_NONE;
          break;
          case SERVICE_PAUSED:
              lvI.iImage      = 2;
              lvI.pszText     = STAT_PAUSED;
          break;
          default:
              lvI.iImage      = 3;
              lvI.pszText     = STAT_NONE;
          break;
      }
      /* Search the items if this is a refresh callback */
      if (uMsg == (WM_USER + 2)) {
          for (i = 0; i < ListView_GetItemCount(hWndList); i++) {
              lvO.iItem = i;
              lvO.mask = LVIF_PARAM;
              ListView_GetItem(hWndList, &lvO);
              lpEntry = (LPAPXSERVENTRY)lvO.lParam;
              if (!lstrcmpW(lpEntry->szServiceName, lpEnt->szServiceName)) {
                  row = lvO.iItem;
                  /* release the old config */
                  apxFree(lpEntry->lpConfig);
                  break;
              }
              else
                  lpEntry = NULL;
          }
      }
      if (row == 0x7FFFFFFF || !lpEntry)
          lpEntry = (LPAPXSERVENTRY) apxPoolAlloc(hPool, sizeof(APXSERVENTRY));
      AplCopyMemory(lpEntry, lpEnt, sizeof(APXSERVENTRY));
      lvI.lParam = (LPARAM)lpEntry;
      if (row == 0x7FFFFFFF)
          row = ListView_InsertItem(hWndList, &lvI);
      else {
          lvI.iItem = row;
          ListView_SetItem(hWndList, &lvI);
      }
      if (row == -1)
          return TRUE; 
  
      ListView_SetItemTextW(hWndList, row, 1, lpEnt->lpConfig->lpDisplayName); 
      i = 2;
      if (lvItems[2].iWidth > 0) {
          if (lpEnt->szServiceDescription)
              ListView_SetItemTextW(hWndList, row, i, lpEnt->szServiceDescription);
          i++;
      }
      if (lvItems[3].iWidth > 0) {
          if (lpEnt->dwStart == SERVICE_DEMAND_START) {
              ListView_SetItemTextW(hWndList, row, i, START_MANUAL);
          }
          else if (lpEnt->dwStart == SERVICE_AUTO_START) {
              ListView_SetItemTextW(hWndList, row, i, START_AUTO);
          }
          else if (lpEnt->dwStart == SERVICE_DISABLED) {
              ListView_SetItemTextW(hWndList, row, i, START_DISABLED);
          }
          else if (lpEnt->dwStart == SERVICE_BOOT_START) {
              ListView_SetItemTextW(hWndList, row, i, START_BOOT);
          }        
          else if (lpEnt->dwStart == SERVICE_SYSTEM_START) {
              ListView_SetItemTextW(hWndList, row, i, START_SYSTEM);
          }
          i++;
      }
      if (lvItems[4].iWidth > 0) {
          ListView_SetItemTextW(hWndList, row, i++, *lpEnt->szObjectName ? 
                                lpEnt->szObjectName : STAT_SYSTEM);
      }
      if (lvItems[5].iWidth > 0) {
          if (lpEnt->stStatusProcess.dwProcessId) {
              wsprintfW(szPid, L"%d", lpEnt->stStatusProcess.dwProcessId);
              ListView_SetItemTextW(hWndList, row, i, szPid);
          }
          i++;
      }
      _currentLitem++;
      return TRUE;
  }
  
  static BOOL loadConfiguration()
  {
      DWORD dwSize, i;
      /* Load the GUI State first */    
      if (IS_INVALID_HANDLE(hRegistry))
          return FALSE;
  
      dwSize = sizeof(APXGUISTATE);
      if (apxRegistryGetBinaryA(hRegistry, APXREG_USER, DISPLAY_KEY, DISPLAY_STATE,
                                (LPBYTE)(&(_gui_store->stState)), &dwSize)) {
          _gui_store->stStartupInfo.wShowWindow = (WORD)_gui_store->stState.dwShow;
          if (_gui_store->stStartupInfo.wShowWindow == SW_MAXIMIZE) {
              _gui_store->stState.rcPosition.top    = CW_USEDEFAULT;
              _gui_store->stState.rcPosition.left   = CW_USEDEFAULT;
              _gui_store->stState.rcPosition.bottom = CW_USEDEFAULT;
              _gui_store->stState.rcPosition.right  = CW_USEDEFAULT;
          }
          if (_gui_store->stState.nColumnWidth[0] > 50)
              lvItems[0].iWidth = _gui_store->stState.nColumnWidth[0];
          if (_gui_store->stState.nColumnWidth[1] > 50)
              lvItems[1].iWidth = _gui_store->stState.nColumnWidth[1];
  
          for (i = 2; i < NUMLVITEMS; i++) {
              lvItems[i].iWidth = _gui_store->stState.nColumnWidth[i];
          }
          _sortColumn   = _gui_store->stState.nUser[0];
          _sortOrder    = _gui_store->stState.nUser[1];
          _currentTimer = _gui_store->stState.nUser[2];
      }
      _filterIname  = apxRegistryGetStringW(hRegistry, APXREG_USER,
                                            SFILT_KEY, SFILT_INAME);
      _filterXname  = apxRegistryGetStringW(hRegistry, APXREG_USER,
                                            SFILT_KEY, SFILT_XNAME);
      _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_USER,
                                            SFILT_KEY, SFILT_ISIMG);
      _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_USER,
                                            SFILT_KEY, SFILT_XSIMG);
      /* try to load system defalut filters */
      if (!_filterIname)
          _filterIname  = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
                                                SFILT_KEY, SFILT_INAME);
      if (!_filterXname)
          _filterXname  = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
                                                SFILT_KEY, SFILT_XNAME);
      if (!_filterIimage)
          _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
                                                SFILT_KEY, SFILT_ISIMG);
      if (!_filterXimage)
          _filterXimage = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
                                                SFILT_KEY, SFILT_XSIMG);
  
      return TRUE;
  }
  
  #define REGSET_FILTER(str, key) \
      APXMACRO_BEGIN              \
      if (str && lstrlenW(str))   \
          apxRegistrySetStrW(hRegistry, APXREG_USER, SFILT_KEY, key, str);    \
      else                                                                    \
          apxRegistryDeleteW(hRegistry, APXREG_USER, SFILT_KEY, key);         \
      APXMACRO_END
  
  static BOOL saveConfiguration()
  {
      DWORD i;
      if (IS_INVALID_HANDLE(hRegistry))
          return FALSE;
      for (i = 0; i < NUMLVITEMS; i++) {
          _gui_store->stState.nColumnWidth[i] = lvItems[i].iWidth;
      }
      _gui_store->stState.nUser[0] = _sortColumn;
      _gui_store->stState.nUser[1] = _sortOrder;
      _gui_store->stState.nUser[2] = _currentTimer;
  
      apxRegistrySetBinaryA(hRegistry, APXREG_USER, DISPLAY_KEY, DISPLAY_STATE,
                            (LPBYTE)(&(_gui_store->stState)), sizeof(APXGUISTATE));
      REGSET_FILTER(_filterIname,  SFILT_INAME);
      REGSET_FILTER(_filterXname,  SFILT_XNAME);
      REGSET_FILTER(_filterIimage, SFILT_ISIMG);
      REGSET_FILTER(_filterXimage, SFILT_XSIMG);
  
      return TRUE;
  }
  
  /* Main program entry
   * Since we are inependant from CRT
   * the arguments are not used
   */
  #ifdef _NO_CRTLIBRARY
  int xMain(void)
  #else
  int WINAPI WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow)
  #endif
  {
      MSG    msg;
  
      apxHandleManagerInitialize();
      hPool     = apxPoolCreate(NULL, 0);
      hService  = apxCreateService(hPool, GENERIC_ALL, TRUE);
  
      _gui_store = apxGuiInitialize(MainWndProc, APSVCMGR_CLASS);
  
      if (!_gui_store) {
          goto cleanup;
      }
      hRegistry = apxCreateRegistry(hPool, KEY_ALL_ACCESS, NULL,
                                    apxLoadResource(IDS_APPLICATION, 0),
                                    APXREG_USER);
      loadConfiguration();
      _gui_store->hMainWnd = CreateWindow(_gui_store->szWndClass,
                                          apxLoadResource(IDS_APPLICATION, 0),
                                          WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                                          _gui_store->stState.rcPosition.left,
                                          _gui_store->stState.rcPosition.top,
                                          _gui_store->stState.rcPosition.right,
                                          _gui_store->stState.rcPosition.bottom,
                                          NULL, NULL,
                                          _gui_store->hInstance,
                                          NULL);
      if (!_gui_store->hMainWnd) {
          goto cleanup;
      }
  
      ShowWindow(_gui_store->hMainWnd, _gui_store->stStartupInfo.wShowWindow);
      UpdateWindow(_gui_store->hMainWnd); 
      SetMenuDefaultItem(GetMenu(_gui_store->hMainWnd), IDMS_PROPERTIES, FALSE);
  
      while (GetMessage(&msg, NULL, 0, 0))  {
          if(!TranslateAccelerator(_gui_store->hMainWnd,
                                   _gui_store->hAccel, &msg)) {
              TranslateMessage(&msg);
              DispatchMessage(&msg);
          }
      }
      saveConfiguration();
  
  cleanup:
      apxFree(_filterIname);
      apxFree(_filterXname);
      apxFree(_filterIimage);
      apxFree(_filterXimage);
      apxFree(_exportFilename);
      apxCloseHandle(hService);
      apxHandleManagerDestroy();
      ExitProcess(0);
      return 0;
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org