2011-12-13 01:12 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbnetio/utils/hbnetio/netiosrv.prg
  * contrib/hbnetio/utils/hbnetio/netiosvc.prg
    + use latest hbwin/wapi capabilities to install service thus
      allowing to change back the default run mode to interactive
    + install service as auto-start
    + added Windows service related option to cmdline help screen
    + display textual error msg on service related errors
    ! minor typo in an error msg
This commit is contained in:
Viktor Szakats
2011-12-13 00:15:18 +00:00
parent 67006279a0
commit 930ee4580e
3 changed files with 37 additions and 14 deletions

View File

@@ -16,10 +16,20 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-12-13 01:12 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbnetio/utils/hbnetio/netiosrv.prg
* contrib/hbnetio/utils/hbnetio/netiosvc.prg
+ use latest hbwin/wapi capabilities to install service thus
allowing to change back the default run mode to interactive
+ install service as auto-start
+ added Windows service related option to cmdline help screen
+ display textual error msg on service related errors
! minor typo in an error msg
2011-12-12 14:01 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/gtwvg/wvgwing.c
* Replaced: hbwin specific argument casting to local implementation.
Maybe this fixes compilation error with BCC55, though I feel that
Maybe this fixes compilation error with BCC55, though I feel that
could be a result of some local modifications, reported by Jacek.
2011-12-12 21:39 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

View File

@@ -203,7 +203,7 @@ PROCEDURE netiosrv_Main( lUI, ... )
HB_Usage()
RETURN
OTHERWISE
netiosrv_LogEvent( hb_StrFormat( "Warning: Unkown command line parameter ignored: %1$s", cParam ) )
netiosrv_LogEvent( hb_StrFormat( "Warning: Unknown command line parameter ignored: %1$s", cParam ) )
ENDCASE
NEXT
@@ -849,6 +849,11 @@ STATIC PROCEDURE HB_Usage()
OutStd( hb_eol() )
OutStd( " -noui don't open interactive console" , hb_eol() )
OutStd( hb_eol() )
#if defined( __PLATFORM__WINDOWS )
OutStd( " -i install as service (requires admin rights)" , hb_eol() )
OutStd( " -u uninstall service (requires admin rights)" , hb_eol() )
OutStd( hb_eol() )
#endif
OutStd( " --version display version header only" , hb_eol() )
OutStd( " -help|--help this help" , hb_eol() )

View File

@@ -6,19 +6,24 @@
PROCEDURE WinMain( ... )
LOCAL cMode := hb_PValue( 1 )
LOCAL cMsg, nError
IF cMode == NIL
cMode := "-s" /* NOTE: Must be the default action */
cMode := ""
ENDIF
SWITCH Lower( cMode )
CASE "-i"
CASE "-install"
IF win_serviceInstall( _SERVICE_NAME, "Harbour NetIO Service" )
IF win_serviceInstall( _SERVICE_NAME, "Harbour NetIO Service", Chr( 34 ) + hb_ProgName() + Chr( 34 ) + " -service", WIN_SERVICE_AUTO_START )
OutStd( "Service has been successfully installed" + hb_eol() )
ELSE
OutStd( "Error installing service: " + hb_ntos( wapi_GetLastError() ) + hb_eol() )
ENDIf
nError := wapi_GetLastError()
cMsg := Space( 128 )
wapi_FormatMessage( ,,,, @cMsg )
OutStd( hb_StrFormat( "Error installing service: %1$d %2$s", nError, cMsg ) + hb_eol() )
ENDIF
EXIT
CASE "-u"
@@ -27,13 +32,11 @@ PROCEDURE WinMain( ... )
IF win_serviceDelete( _SERVICE_NAME )
OutStd( "Service has been deleted" + hb_eol() )
ELSE
OutStd( "Error deleting service: " + hb_ntos( wapi_GetLastError() ) + hb_eol() )
ENDIf
EXIT
CASE "-a"
netiosrv_Main( .T., ... ) /* Interactive */
nError := wapi_GetLastError()
cMsg := Space( 128 )
wapi_FormatMessage( ,,,, @cMsg )
OutStd( hb_StrFormat( "Error uninstalling service: %1$d %2$s", nError, cMsg ) + hb_eol() )
ENDIF
EXIT
CASE "-s"
@@ -42,10 +45,15 @@ PROCEDURE WinMain( ... )
IF win_serviceStart( _SERVICE_NAME, @hbnetio_WinServiceEntry() )
OutStd( "Service has started OK" + hb_eol() )
ELSE
OutStd( "Service has had some problems: " + hb_ntos( wapi_GetLastError() ) + hb_eol() )
OutStd( hb_StrFormat( "Service has had some problems: %1$d", wapi_GetLastError() ) + hb_eol() )
ENDIF
EXIT
OTHERWISE
netiosrv_Main( .T., ... ) /* Interactive */
EXIT
ENDSWITCH
RETURN