diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 305e03d56c..973e48ef00 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2011-03-09 18:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_svc.c + * contrib/hbwin/tests/testsvc.prg + + WIN_SERVICESTART() changed to accept codeblock and + function reference as second parameter (was string). + INCOMPATIBLE: Pls update your code to use new method. + NOTE: If someone knows how to add string support without + duplicating code and other hacks, pls do, however + I think that codeblock and function reference is + much more modern and fool-proof solution. + 2011-03-09 17:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/qtgui/hbqt_init.cpp * contrib/hbqt/qtcore/hbqt_init.cpp diff --git a/harbour/contrib/hbwin/tests/testsvc.prg b/harbour/contrib/hbwin/tests/testsvc.prg index 1c0510a97f..2983f9224c 100644 --- a/harbour/contrib/hbwin/tests/testsvc.prg +++ b/harbour/contrib/hbwin/tests/testsvc.prg @@ -81,7 +81,7 @@ PROCEDURE Main( cMode ) CASE "S" - IF win_serviceStart( _SERVICE_NAME, "SrvMain" ) + IF win_serviceStart( _SERVICE_NAME, @SrvMain() ) ? "Service has started OK" ELSE ? "Service has had some problems: " + hb_ntos( wapi_GetLastError() ) diff --git a/harbour/contrib/hbwin/win_svc.c b/harbour/contrib/hbwin/win_svc.c index f1604a29c6..b66f432408 100644 --- a/harbour/contrib/hbwin/win_svc.c +++ b/harbour/contrib/hbwin/win_svc.c @@ -63,7 +63,7 @@ static SERVICE_STATUS s_ServiceStatus; static SERVICE_STATUS_HANDLE s_hStatus; -static PHB_SYMB s_sHarbourEntryFunc = NULL; +static PHB_ITEM s_pHarbourEntryFunc = NULL; static TCHAR s_lpServiceName[ 256 ]; /* Control handler function */ @@ -99,7 +99,7 @@ static VOID WINAPI hbwin_SvcMainFunction( DWORD dwArgc, LPTSTR * lpszArgv ) if( s_hStatus != ( SERVICE_STATUS_HANDLE ) 0 ) { - if( s_sHarbourEntryFunc != NULL ) + if( s_pHarbourEntryFunc != NULL ) { if( hb_vmRequestReenterExt() ) { @@ -110,8 +110,8 @@ static VOID WINAPI hbwin_SvcMainFunction( DWORD dwArgc, LPTSTR * lpszArgv ) s_ServiceStatus.dwCurrentState = SERVICE_RUNNING; SetServiceStatus( s_hStatus, &s_ServiceStatus ); - hb_vmPushSymbol( s_sHarbourEntryFunc ); - hb_vmPushNil(); + hb_vmPushEvalSym(); + hb_vmPush( s_pHarbourEntryFunc ); for( i = 1; i < dwArgc; ++i ) { @@ -126,7 +126,7 @@ static VOID WINAPI hbwin_SvcMainFunction( DWORD dwArgc, LPTSTR * lpszArgv ) HB_TCHAR_FREE( pszArg ); } - hb_vmProc( ( HB_USHORT ) iArgCount ); + hb_vmSend( ( HB_USHORT ) iArgCount ); hb_vmRequestRestore(); } @@ -295,18 +295,23 @@ HB_FUNC( WIN_SERVICESTART ) { HB_BOOL bRetVal = HB_FALSE; #if ! defined( HB_OS_WIN_CE ) + PHB_ITEM pEntryFunc; SERVICE_TABLE_ENTRY lpServiceTable[ 2 ]; HB_ITEMCOPYSTR( hb_param( 1, HB_IT_STRING ), s_lpServiceName, HB_SIZEOFARRAY( s_lpServiceName ) ); - s_sHarbourEntryFunc = hb_itemGetSymbol( hb_param( 2, HB_IT_SYMBOL ) ); - if( s_sHarbourEntryFunc == NULL && HB_ISCHAR( 2 ) ) + + if( s_pHarbourEntryFunc ) { - PHB_DYNS pDynSym = hb_dynsymFindName( hb_parc( 2 ) ); - if( pDynSym && hb_dynsymIsFunction( pDynSym ) ) - s_sHarbourEntryFunc = hb_dynsymSymbol( pDynSym ); + hb_itemRelease( s_pHarbourEntryFunc ); + s_pHarbourEntryFunc = NULL; } + pEntryFunc = hb_param( 2, HB_IT_BLOCK | HB_IT_SYMBOL ); + + if( pEntryFunc ) + s_pHarbourEntryFunc = hb_itemNew( pEntryFunc ); + lpServiceTable[ 0 ].lpServiceName = s_lpServiceName; lpServiceTable[ 0 ].lpServiceProc = ( LPSERVICE_MAIN_FUNCTION ) hbwin_SvcMainFunction;