From 55af9daf4b2ee3a99eeeb9851aba8d1d43302dce Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 May 2010 06:52:49 +0000 Subject: [PATCH] 2010-05-21 08:52 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_svc.c + WIN_SERVICEINSTALL(): Extended to accept 3rd parameter for the full filename of the service executable. This makes it possible to install other .exes not just self. --- harbour/ChangeLog | 6 ++++++ harbour/contrib/hbwin/win_svc.c | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index aef30c27b5..92d8303579 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-05-21 08:52 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_svc.c + + WIN_SERVICEINSTALL(): Extended to accept 3rd parameter + for the full filename of the service executable. This + makes it possible to install other .exes not just self. + 2010-05-20 16:49 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/generator/hbqtgen.prg ! Two small fixes. No code regeneration required. diff --git a/harbour/contrib/hbwin/win_svc.c b/harbour/contrib/hbwin/win_svc.c index a8924c4a08..283779cc27 100644 --- a/harbour/contrib/hbwin/win_svc.c +++ b/harbour/contrib/hbwin/win_svc.c @@ -185,10 +185,23 @@ HB_FUNC( WIN_SERVICESTOP ) HB_FUNC( WIN_SERVICEINSTALL ) { HB_BOOL bRetVal = HB_FALSE; -#if ! defined( HB_OS_WIN_CE ) - TCHAR lpPath[ MAX_PATH ]; - if( GetModuleFileName( NULL, lpPath, HB_SIZEOFARRAY( lpPath ) ) ) +#if ! defined( HB_OS_WIN_CE ) + + void * hPath; + LPCTSTR lpPath = HB_PARSTR( 3, &hPath, NULL ); + + TCHAR lpPathBuffer[ MAX_PATH ]; + + if( lpPath == NULL ) + { + if( GetModuleFileName( NULL, lpPathBuffer, HB_SIZEOFARRAY( lpPathBuffer ) ) ) + lpPath = lpPathBuffer; + else + hbwapi_SetLastError( GetLastError() ); + } + + if( lpPath ) { SC_HANDLE schSCM = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS ); @@ -233,8 +246,8 @@ HB_FUNC( WIN_SERVICEINSTALL ) else hbwapi_SetLastError( GetLastError() ); } - else - hbwapi_SetLastError( GetLastError() ); + + hb_strfree( hPath ); #endif hb_retl( bRetVal );