diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4b23960450..77461bb63c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-05-27 20:23 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbmisc/calldll.prg + + HB_DYNCALL1() will now cut the number of parameters + according to passed nCount parameter, just to mimic + exact behavior of original function. + + + contrib/hbmisc/tests/testcall.prg + + Added test code for CALLDLL32() and HB_DYNCALL1(). + + * contrib/hbwin/tests/testcopy.prg + * Copyright year. + 2010-05-27 19:57 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmisc/Makefile + contrib/hbmisc/calldll.prg diff --git a/harbour/contrib/hbmisc/calldll.prg b/harbour/contrib/hbmisc/calldll.prg index ca539c7def..56bafd2ba8 100644 --- a/harbour/contrib/hbmisc/calldll.prg +++ b/harbour/contrib/hbmisc/calldll.prg @@ -63,9 +63,10 @@ PROCEDURE UNLOADALLDLL() FUNCTION CALLDLL32( cFunction, cLibrary, ... ) RETURN HB_DYNACALL1( cFunction, cLibrary, NIL, ... ) -FUNCTION HB_DYNACALL1( cFunction, cLibrary, nCount, ... ) +#define _DEF_CALLCONV_ HB_DYN_CTYPE_CHAR_PTR - HB_SYMBOL_UNUSED( nCount ) +FUNCTION HB_DYNACALL1( cFunction, cLibrary, nCount, ... ) + LOCAL aParams IF ISCHARACTER( cFunction ) .AND. ; ISCHARACTER( cLibrary ) @@ -74,7 +75,16 @@ FUNCTION HB_DYNACALL1( cFunction, cLibrary, nCount, ... ) s_hDLL[ cLibrary ] := hb_LibLoad( cLibrary ) ENDIF - RETURN hb_dynCall( { cFunction, s_hDLL[ cLibrary ], HB_DYN_CTYPE_CHAR_PTR }, ... ) + IF ISNUMBER( nCount ) + IF nCount == 0 + RETURN hb_dynCall( { cFunction, s_hDLL[ cLibrary ], _DEF_CALLCONV_ } ) + ELSEIF nCount >= 0 .AND. nCount < PCount() - 3 + aParams := ASize( hb_AParams(), nCount ) + RETURN hb_dynCall( { cFunction, s_hDLL[ cLibrary ], _DEF_CALLCONV_ }, hb_arrayToParams( aParams ) ) + ENDIF + ELSE + RETURN hb_dynCall( { cFunction, s_hDLL[ cLibrary ], _DEF_CALLCONV_ }, ... ) + ENDIF ENDIF RETURN NIL diff --git a/harbour/contrib/hbmisc/tests/testcall.prg b/harbour/contrib/hbmisc/tests/testcall.prg new file mode 100644 index 0000000000..08665d0d33 --- /dev/null +++ b/harbour/contrib/hbmisc/tests/testcall.prg @@ -0,0 +1,25 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://www.harbour-project.org + * + */ + +PROCEDURE Main() + + ? CALLDLL32( "curl_version", "libcurl.dll" ) + + ? CALLDLL32( "SSLeay_version", "libeay32.dll", 0 ) + ? CALLDLL32( "SSLeay_version", "libeay32.dll", 1 ) + ? CALLDLL32( "SSLeay_version", "libeay32.dll", 2 ) + ? CALLDLL32( "SSLeay_version", "libeay32.dll", 3 ) + ? CALLDLL32( "SSLeay_version", "libeay32.dll", 4 ) + + ? HB_DYNACALL1( "SSLeay_version", "libeay32.dll", 0, 4 ) + + RETURN diff --git a/harbour/contrib/hbwin/tests/testcopy.prg b/harbour/contrib/hbwin/tests/testcopy.prg index 2791119370..536b08db85 100644 --- a/harbour/contrib/hbwin/tests/testcopy.prg +++ b/harbour/contrib/hbwin/tests/testcopy.prg @@ -5,7 +5,7 @@ /* * Harbour Project source code: * - * Copyright 2009 Viktor Szakats (harbour.01 syenar.hu) + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) * www - http://www.harbour-project.org * */