2010-02-16 09:42 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_dllc.c
* contrib/hbwin/tests/testdll.prg
* Replaced WIN_DLLCALL() with portable (non Windows-specific)
HB_DYNCALL(), which uses Harbour core function to handle
dynamic libs. This also means there is two former feature lost:
- Specifiying function by (numeric) ordinal.
- Passing function pointer directly.
; TODO: Make the default calling convention cdecl?
; TODO: Move 'hbdyn' subsystem to core after review.
; HB_DYNCALL() should be called as follows:
HB_DYNCALL( <pFunction> | <aFunction>, ... ) -> <xResult>
where <aFunction> can be:
{ <cFunction>, <cLibrary> | <pLibrary> [, <nFuncFlags> [, <nArgFlags1>, ..., <nArgFlagsn> ]] }
where
<nFuncFlags> can be:
hb_bitOr( HB_DYN_CTYPE_*, HB_DYN_ENC_*, HB_DYN_CALLCONV_* )
<nArgFlags*> can be:
hb_bitOr( HB_DYN_CTYPE_*, HB_DYN_ENC_* )
* contrib/hbwin/win_dllf.prg
* Renamed WIN_DLLCALLFOXPRO() to HB_DYNCALLFOXPRO().
This commit is contained in:
@@ -17,10 +17,37 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-16 09:42 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbwin/win_dllc.c
|
||||
* contrib/hbwin/tests/testdll.prg
|
||||
* Replaced WIN_DLLCALL() with portable (non Windows-specific)
|
||||
HB_DYNCALL(), which uses Harbour core function to handle
|
||||
dynamic libs. This also means there is two former feature lost:
|
||||
- Specifiying function by (numeric) ordinal.
|
||||
- Passing function pointer directly.
|
||||
; TODO: Make the default calling convention cdecl?
|
||||
; TODO: Move 'hbdyn' subsystem to core after review.
|
||||
|
||||
; HB_DYNCALL() should be called as follows:
|
||||
|
||||
HB_DYNCALL( <pFunction> | <aFunction>, ... ) -> <xResult>
|
||||
|
||||
where <aFunction> can be:
|
||||
{ <cFunction>, <cLibrary> | <pLibrary> [, <nFuncFlags> [, <nArgFlags1>, ..., <nArgFlagsn> ]] }
|
||||
|
||||
where
|
||||
<nFuncFlags> can be:
|
||||
hb_bitOr( HB_DYN_CTYPE_*, HB_DYN_ENC_*, HB_DYN_CALLCONV_* )
|
||||
<nArgFlags*> can be:
|
||||
hb_bitOr( HB_DYN_CTYPE_*, HB_DYN_ENC_* )
|
||||
|
||||
* contrib/hbwin/win_dllf.prg
|
||||
* Renamed WIN_DLLCALLFOXPRO() to HB_DYNCALLFOXPRO().
|
||||
|
||||
2010-02-15 19:22 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbide/ideprojmanager.prg
|
||||
+ Project Management: first steps to integrate with .hbp engine.
|
||||
% 'Project Location' made sensitive to valid/invalid path
|
||||
% 'Project Location' made sensitive to valid/invalid path
|
||||
with different background color.
|
||||
|
||||
2010-02-15 23:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
|
||||
@@ -54,9 +54,9 @@ PROCEDURE Main()
|
||||
IF hb_FileExists( "libcurl.dll" )
|
||||
hDLL := wapi_LoadLibrary( "libcurl.dll" )
|
||||
? GetProcAddress( hDLL, "curl_version" )
|
||||
? win_dllCall( { "curl_version", hDLL, HB_DYN_CTYPE_CHAR_PTR } )
|
||||
? hb_dynCall( { "curl_version", hDLL, HB_DYN_CTYPE_CHAR_PTR } )
|
||||
wapi_FreeLibrary( hDLL )
|
||||
? win_dllCall( { "curl_version", "libcurl.dll", HB_DYN_CTYPE_CHAR_PTR } )
|
||||
? hb_dynCall( { "curl_version", "libcurl.dll", HB_DYN_CTYPE_CHAR_PTR } )
|
||||
ENDIF
|
||||
|
||||
/* Force Windows not to show dragged windows contents */
|
||||
@@ -77,27 +77,27 @@ PROCEDURE Main()
|
||||
? "ValType( hDLL ): ", ValType( hDLL )
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "WIN_DLLCALL (BOOL retval): ", win_dllCall( { "SHGetSpecialFolderPath", hDLL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "HB_DYNCALL (BOOL retval): ", hb_dynCall( { "SHGetSpecialFolderPath", hDLL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "WIN_DLLCALL (BOOL retval): ", win_dllCall( { GetProcAddress( hDLL, "SHGetSpecialFolderPath" ), HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "HB_DYNCALL (BOOL retval): ", hb_dynCall( { GetProcAddress( hDLL, "SHGetSpecialFolderPath" ), HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
? "WIN_DLLCALL: ", win_dllCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData ) // WRONG
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData ) // WRONG
|
||||
? "cData:", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "WIN_DLLCALL (PARAMS): ", win_dllCall( { "SHGetSpecialFolderPath", hDLL, NIL, NIL, NIL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "HB_DYNCALL (PARAMS): ", hb_dynCall( { "SHGetSpecialFolderPath", hDLL, NIL, NIL, NIL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "WIN_DLLCALL: ", win_dllCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "cData BEFORE: ", cData
|
||||
? "WIN_DLLCALL (MISSING @1): ", win_dllCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
|
||||
? "HB_DYNCALL (MISSING @1): ", hb_dynCall( { "SHGetFolderPath", hDLL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
|
||||
? "cData AFTER: ", cData
|
||||
? "------"
|
||||
wapi_FreeLibrary( hDLL )
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Windows DLL handling function
|
||||
* Calling function from dynamic library (HB_DYNCALL())
|
||||
*
|
||||
* Copyright 2009-2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
@@ -50,18 +50,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbwin.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbdyn.h"
|
||||
|
||||
HB_FUNC( WIN_DLLCALL )
|
||||
HB_FUNC( HB_DYNCALL )
|
||||
{
|
||||
PHB_ITEM pParam = hb_param( 1, HB_IT_POINTER | HB_IT_ARRAY );
|
||||
int * piArgFlags = NULL;
|
||||
int iFuncFlags = HB_DYN_CALLCONV_STDCALL;
|
||||
HB_BOOL bFreeDLL = HB_FALSE;
|
||||
|
||||
HMODULE hDLL = NULL;
|
||||
PHB_ITEM pLibraryHandle = NULL;
|
||||
HB_BOOL bFreeLibrary = HB_FALSE;
|
||||
void * pFunctionPtr = NULL;
|
||||
|
||||
if( pParam )
|
||||
@@ -75,32 +75,26 @@ HB_FUNC( WIN_DLLCALL )
|
||||
PHB_ITEM pFunction = hb_arrayGetItemPtr( pParam, 1 );
|
||||
HB_SIZE nBasePos = 2;
|
||||
|
||||
#if 0
|
||||
if( HB_IS_POINTER( pFunction ) )
|
||||
pFunctionPtr = hb_itemGetPtr( pFunction );
|
||||
else if( ( HB_IS_NUMERIC( pFunction ) || HB_IS_STRING( pFunction ) ) && nLen >= nBasePos )
|
||||
else ...
|
||||
#endif
|
||||
if( HB_IS_STRING( pFunction ) && nLen >= nBasePos )
|
||||
{
|
||||
PHB_ITEM pLibrary = hb_arrayGetItemPtr( pParam, nBasePos );
|
||||
|
||||
if( HB_IS_STRING( pLibrary ) )
|
||||
{
|
||||
void * hFileName;
|
||||
hDLL = LoadLibrary( HB_ITEMGETSTR( pLibrary, &hFileName, NULL ) );
|
||||
hb_strfree( hFileName );
|
||||
if( ( HB_PTRDIFF ) hDLL < 32 )
|
||||
hDLL = NULL;
|
||||
else
|
||||
bFreeDLL = HB_TRUE;
|
||||
pLibraryHandle = hb_libLoad( pLibrary, NULL );
|
||||
if( pLibraryHandle )
|
||||
bFreeLibrary = HB_TRUE;
|
||||
}
|
||||
else if( HB_IS_POINTER( pLibrary ) )
|
||||
hDLL = ( HMODULE ) hb_itemGetPtr( pLibrary );
|
||||
else if( hb_libHandle( pLibrary ) )
|
||||
pLibraryHandle = pLibrary;
|
||||
|
||||
if( hDLL )
|
||||
{
|
||||
HB_BOOL bWIDE;
|
||||
pFunctionPtr = ( void * ) hbwin_getprocaddress( hDLL, pFunction, &bWIDE );
|
||||
if( bWIDE )
|
||||
iFuncFlags |= HB_DYN_ENC_UTF16;
|
||||
}
|
||||
if( pLibraryHandle )
|
||||
pFunctionPtr = hb_libSymAddr( pLibraryHandle, hb_itemGetCPtr( pFunction ) );
|
||||
|
||||
++nBasePos;
|
||||
}
|
||||
@@ -133,6 +127,6 @@ HB_FUNC( WIN_DLLCALL )
|
||||
if( piArgFlags )
|
||||
hb_xfree( piArgFlags );
|
||||
|
||||
if( bFreeDLL )
|
||||
FreeLibrary( hDLL );
|
||||
if( bFreeLibrary )
|
||||
hb_libFree( pLibraryHandle );
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Windows .dll support (high-level)
|
||||
* Calling function from dynamic library (HB_DYNCALLFOXPRO())
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
@@ -58,7 +58,7 @@ DECLARE [cFunctionType] FunctionName IN LibraryName [AS AliasName]
|
||||
[cParamType1 [@] ParamName1, cParamType2 [@] ParamName2, ...]
|
||||
*/
|
||||
|
||||
FUNCTION win_dllCallFoxPro( cCommand, ... )
|
||||
FUNCTION hb_dynCallFoxPro( cCommand, ... )
|
||||
LOCAL aParam
|
||||
|
||||
LOCAL cFunction
|
||||
@@ -131,4 +131,4 @@ FUNCTION win_dllCallFoxPro( cCommand, ... )
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
RETURN win_dllCall( aParam, ... )
|
||||
RETURN hb_dynCall( aParam, ... )
|
||||
|
||||
Reference in New Issue
Block a user