2010-02-17 03:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/fstemp.c
! Using hb_fsTempDir() in HB_FTEMPCREATEEX() instead of
old solution. This should fix it for some non-*nix
platforms where *nix specific TEMPDIR envvar was used
to determine temp directory.
* contrib/hbwin/Makefile
* include/Makefile
* src/rtl/Makefile
- contrib/hbwin/hbdyn.ch
+ include/hbdyn.ch
- contrib/hbwin/hbdyn.c
+ src/rtl/hbdyn.c
- contrib/hbwin/win_dllc.c
+ src/rtl/hbdynhb.c
- contrib/hbwin/tests/testdll.c
+ tests/testdyn.c
- contrib/hbwin/tests/testdll.prg
+ tests/testdyn.prg
- contrib/hbwin/tests/testdll1.prg
+ tests/testdyn1.prg
- contrib/hbwin/hbdyn.h
* include/hbapi.h
* Moved dynamic library call related functions to
core (RTL).
* Windows specific test code (currently all) guarded
for platform.
* Changed default calling convention to cdecl.
Tests adaptd accordingly.
* Terminology change: 'dll' -> 'dynamic library'
; HB_DYNCALL() is now part of core Harbour, and it's
platform independent. It's platform (ABI) dependent though,
and currently x64 and x86/stdcall/syscall/cdecl
is supported and these were tested (except OS/2 syscall).
* contrib/hbwin/hbwin.h
* contrib/hbwin/win_misc.c
* contrib/hbwin/legacycd.c
* Low level hbwin_getprocaddress() function moved
to legacy file and made static.
* contrib/xpp/Makefile
* contrib/xpp/dllx.c
* contrib/xpp/xpp.hbc
+ Enabled DLL*() functions for all platforms.
- Deleted dependence on hbwin library.
* contrib/xpp/tests/testdll.prg
* Windows specific parts (currently the whole test) guarded
for platform.
* contrib/hbct/Makefile
- contrib/hbct/diskhb.prg
* contrib/hbct/disk.c
* contrib/xhb/Makefile
+ contrib/xhb/diskhb.prg
* GETVOLINFO() moved from hbct to xhb.
* ChangeLog
* Marked some TODO/TOFIX items as DONE.
This commit is contained in:
@@ -17,6 +17,68 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-17 03:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/rtl/fstemp.c
|
||||
! Using hb_fsTempDir() in HB_FTEMPCREATEEX() instead of
|
||||
old solution. This should fix it for some non-*nix
|
||||
platforms where *nix specific TEMPDIR envvar was used
|
||||
to determine temp directory.
|
||||
|
||||
* contrib/hbwin/Makefile
|
||||
* include/Makefile
|
||||
* src/rtl/Makefile
|
||||
- contrib/hbwin/hbdyn.ch
|
||||
+ include/hbdyn.ch
|
||||
- contrib/hbwin/hbdyn.c
|
||||
+ src/rtl/hbdyn.c
|
||||
- contrib/hbwin/win_dllc.c
|
||||
+ src/rtl/hbdynhb.c
|
||||
- contrib/hbwin/tests/testdll.c
|
||||
+ tests/testdyn.c
|
||||
- contrib/hbwin/tests/testdll.prg
|
||||
+ tests/testdyn.prg
|
||||
- contrib/hbwin/tests/testdll1.prg
|
||||
+ tests/testdyn1.prg
|
||||
- contrib/hbwin/hbdyn.h
|
||||
* include/hbapi.h
|
||||
* Moved dynamic library call related functions to
|
||||
core (RTL).
|
||||
* Windows specific test code (currently all) guarded
|
||||
for platform.
|
||||
* Changed default calling convention to cdecl.
|
||||
Tests adaptd accordingly.
|
||||
* Terminology change: 'dll' -> 'dynamic library'
|
||||
; HB_DYNCALL() is now part of core Harbour, and it's
|
||||
platform independent. It's platform (ABI) dependent though,
|
||||
and currently x64 and x86/stdcall/syscall/cdecl
|
||||
is supported and these were tested (except OS/2 syscall).
|
||||
|
||||
* contrib/hbwin/hbwin.h
|
||||
* contrib/hbwin/win_misc.c
|
||||
* contrib/hbwin/legacycd.c
|
||||
* Low level hbwin_getprocaddress() function moved
|
||||
to legacy file and made static.
|
||||
|
||||
* contrib/xpp/Makefile
|
||||
* contrib/xpp/dllx.c
|
||||
* contrib/xpp/xpp.hbc
|
||||
+ Enabled DLL*() functions for all platforms.
|
||||
- Deleted dependence on hbwin library.
|
||||
|
||||
* contrib/xpp/tests/testdll.prg
|
||||
* Windows specific parts (currently the whole test) guarded
|
||||
for platform.
|
||||
|
||||
* contrib/hbct/Makefile
|
||||
- contrib/hbct/diskhb.prg
|
||||
* contrib/hbct/disk.c
|
||||
* contrib/xhb/Makefile
|
||||
+ contrib/xhb/diskhb.prg
|
||||
* GETVOLINFO() moved from hbct to xhb.
|
||||
|
||||
* ChangeLog
|
||||
* Marked some TODO/TOFIX items as DONE.
|
||||
|
||||
2010-02-17 01:42 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbmysql/mysql.c
|
||||
! Typo.
|
||||
@@ -72,7 +134,7 @@
|
||||
; NOTE: Please review this code. It's the first time I
|
||||
used GC references in code, and it may be wrong.
|
||||
; TODO: Remove hbwin dependence after having moved hb_dynCall()
|
||||
from hbwin to core.
|
||||
from hbwin to core. [DONE]
|
||||
|
||||
+ contrib/xpp/tests/hbmk.hbm
|
||||
+ Added missing file from prev commit.
|
||||
@@ -203,8 +265,8 @@
|
||||
- Passing function pointer directly.
|
||||
- Automatic lookup for function names with 'A' and 'W' ending.
|
||||
- Automatic UNICODE encoding for functions ending with 'W'.
|
||||
; TODO: Make the default calling convention cdecl?
|
||||
; TODO: Move 'hbdyn' subsystem to core after review.
|
||||
; TODO: Make the default calling convention cdecl? [DONE]
|
||||
; TODO: Move 'hbdyn' subsystem to core after review. [DONE - no review yet though]
|
||||
|
||||
; HB_DYNCALL() should be called as follows:
|
||||
|
||||
@@ -2860,7 +2922,7 @@
|
||||
! Fixed to not use -fomit-frame-pointer option for debug builds.
|
||||
! Hack added to disable -fomit-frame-pointer for hbwin lib.
|
||||
; TOFIX: Fix hb_Dynacall() to not be sensitive on this option
|
||||
in mingw builds. Is it possible?
|
||||
in mingw builds. Is it possible? [DONE]
|
||||
|
||||
2010-02-06 16:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/rtl/filesys.c
|
||||
@@ -3300,7 +3362,7 @@
|
||||
the temp directory will be wrongly calculated by checking
|
||||
TMPDIR envvar. Such envvar seems *nix specific.
|
||||
If new hb_fsTempDir() will be tested, above can be fixed
|
||||
by using this new function.
|
||||
by using this new function. [DONE]
|
||||
|
||||
* package/winuni/RELNOTES
|
||||
+ Noted update to Firebird 2.5.0rc1
|
||||
@@ -5831,7 +5893,7 @@
|
||||
+ Using new UNICODE macros in TRUENAME(), GETVOLINFO() and VOLSERIAL().
|
||||
! GETVOLINFO(), which is not a CT function, got moved
|
||||
to a separate source file to avoid name collisions.
|
||||
; TOFIX: It should be moved to xhb lib eventually.
|
||||
; TOFIX: It should be moved to xhb lib eventually. [DONE]
|
||||
|
||||
* contrib/hbct/ctnet.c
|
||||
* Cleaned NETREDIR() and NETRMTNAME() functions.
|
||||
|
||||
@@ -100,7 +100,6 @@ PRG_SOURCES := \
|
||||
ctmisc.prg \
|
||||
ctrand.prg \
|
||||
cttime.prg \
|
||||
diskhb.prg \
|
||||
fcopy.prg \
|
||||
getinfo.prg \
|
||||
getinput.prg \
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* DirName() - Ready.
|
||||
* DriveType() - Ready. corrected <ptucker@sympatico.ca>
|
||||
* Volume() - Ready.
|
||||
* GetVolInfo() - Ready. This function is new.
|
||||
* VolSerial() - Ready.
|
||||
*
|
||||
* Copyright 2004 Phil Krylov <phil@newstar.rinet.ru>
|
||||
|
||||
@@ -10,7 +10,6 @@ LIBNAME := hbwin
|
||||
|
||||
C_SOURCES := \
|
||||
axcore.c \
|
||||
hbdyn.c \
|
||||
legacycd.c \
|
||||
legacyco.c \
|
||||
legacycp.c \
|
||||
@@ -35,7 +34,6 @@ C_SOURCES := \
|
||||
win_bmpd.c \
|
||||
win_com.c \
|
||||
win_dlg.c \
|
||||
win_dllc.c \
|
||||
win_misc.c \
|
||||
win_osc.c \
|
||||
win_prn1.c \
|
||||
@@ -56,13 +54,11 @@ PRG_SOURCES := \
|
||||
win_tprn.prg \
|
||||
|
||||
C_HEADERS := \
|
||||
hbdyn.h \
|
||||
hbwapi.h \
|
||||
hbwin.h \
|
||||
hbwinole.h \
|
||||
|
||||
PRG_HEADERS := \
|
||||
hbdyn.ch \
|
||||
hbwin.ch \
|
||||
|
||||
ifneq ($(filter $(HB_PLATFORM),win wce),)
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Dynamic call (low-level header)
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HBDYN_H
|
||||
#define __HBDYN_H
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbdyn.ch"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
extern HB_EXPORT void hb_dynCall( int iFuncFlags, void * pFunction, int iParams, int iFirst, int * piArgFlags );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
#endif /* __HBDYN_H */
|
||||
@@ -93,10 +93,7 @@
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
extern HB_EXPORT int hbwin_bitmapType( const void * pImgBuf, HB_SIZE size );
|
||||
extern FARPROC hbwin_getprocaddress( HMODULE hDLL, PHB_ITEM pParam, HB_BOOL * pbWIDE );
|
||||
|
||||
extern HB_EXPORT void hb_dynCall( int iFuncFlags, void * pFunction, int iParams, int iFirst, int * piArgFlags );
|
||||
extern HB_EXPORT int hbwin_bitmapType( const void * pImgBuf, HB_SIZE size );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@
|
||||
[vszakats] */
|
||||
|
||||
#include "hbwin.h"
|
||||
#include "hbdyn.h"
|
||||
#include "hbapiitm.h"
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#if ! defined( HB_LEGACY_LEVEL3 ) && ! defined( HB_WIN_LEGACY_LEVEL_OFF )
|
||||
#define HB_WIN_LEGACY_LEVEL_OFF
|
||||
@@ -113,6 +115,59 @@ HB_FUNC( CALLDLLTYPED )
|
||||
hb_dynCall( HB_DYN_CALLCONV_STDCALL | hb_parni( 2 ), hb_parptr( 1 ), hb_pcount(), 3, NULL );
|
||||
}
|
||||
|
||||
static FARPROC hbwin_getprocaddress( HMODULE hDLL, PHB_ITEM pParam, HB_BOOL * pbWIDE )
|
||||
{
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
void * hStr;
|
||||
HB_SIZE nLen;
|
||||
LPCWSTR szProc = hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &hStr, &nLen );
|
||||
FARPROC lpFunction = GetProcAddress( hDLL, szProc ? szProc :
|
||||
( LPCWSTR ) ( HB_PTRDIFF ) ( hb_itemGetNI( pParam ) & 0x0FFFF ) );
|
||||
|
||||
if( ! lpFunction && szProc ) /* try with WIDE suffix? */
|
||||
{
|
||||
LPWSTR pszProcW = ( LPWSTR ) hb_xgrab( ( nLen + 2 ) * sizeof( WCHAR ) );
|
||||
memcpy( pszProcW, szProc, nLen * sizeof( WCHAR ) );
|
||||
pszProcW[ nLen++ ] = L'W';
|
||||
pszProcW[ nLen++ ] = 0;
|
||||
lpFunction = GetProcAddress( hDLL, pszProcW );
|
||||
hb_xfree( pszProcW );
|
||||
}
|
||||
hb_strfree( hStr );
|
||||
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_TRUE;
|
||||
#else
|
||||
const char * szProc = hb_itemGetCPtr( pParam );
|
||||
FARPROC lpFunction = GetProcAddress( hDLL, szProc ? szProc :
|
||||
( LPCSTR ) ( HB_PTRDIFF ) ( hb_itemGetNI( pParam ) & 0x0FFFF ) );
|
||||
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_FALSE;
|
||||
|
||||
#if defined( UNICODE )
|
||||
if( ! lpFunction && szProc ) /* try with WIDE suffix? */
|
||||
{
|
||||
char * pszFuncName = hb_xstrcpy( NULL, szProc, "W", NULL );
|
||||
lpFunction = GetProcAddress( hDLL, pszFuncName );
|
||||
hb_xfree( pszFuncName );
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ! lpFunction && szProc ) /* try with ANSI suffix? */
|
||||
{
|
||||
char * pszFuncName = hb_xstrcpy( NULL, szProc, "A", NULL );
|
||||
lpFunction = GetProcAddress( hDLL, pszFuncName );
|
||||
hb_xfree( pszFuncName );
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_FALSE;
|
||||
}
|
||||
#endif
|
||||
return lpFunction;
|
||||
}
|
||||
|
||||
HB_FUNC( GETPROCADDRESS )
|
||||
{
|
||||
HMODULE hDLL;
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DLL call demonstration.
|
||||
*
|
||||
* Copyright 2008 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#define MB_OK 0x00000000
|
||||
#define MB_OKCANCEL 0x00000001
|
||||
#define MB_ABORTRETRYIGNORE 0x00000002
|
||||
#define MB_YESNOCANCEL 0x00000003
|
||||
#define MB_YESNO 0x00000004
|
||||
#define MB_RETRYCANCEL 0x00000005
|
||||
#define MB_CANCELTRYCONTINUE 0x00000006
|
||||
#define MB_ICONHAND 0x00000010
|
||||
#define MB_ICONQUESTION 0x00000020
|
||||
#define MB_ICONEXCLAMATION 0x00000030
|
||||
#define MB_ICONASTERISK 0x00000040
|
||||
#define MB_USERICON 0x00000080
|
||||
#define MB_DEFBUTTON2 0x00000100
|
||||
#define MB_DEFBUTTON3 0x00000200
|
||||
#define MB_DEFBUTTON4 0x00000300
|
||||
#define MB_SYSTEMMODAL 0x00001000
|
||||
#define MB_TASKMODAL 0x00002000
|
||||
#define MB_HELP 0x00004000
|
||||
#define MB_NOFOCUS 0x00008000
|
||||
#define MB_SETFOREGROUND 0x00010000
|
||||
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000
|
||||
#define MB_TOPMOST 0x00040000
|
||||
#define MB_RIGHT 0x00080000
|
||||
#define MB_RTLREADING 0x00100000
|
||||
|
||||
#define CSIDL_APPDATA 0x001a /* <username>\Application Data */
|
||||
#define CSIDL_ADMINTOOLS 0x0030 /* <username>\Start Menu\Programs\Administrative Tools */
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL hLib
|
||||
LOCAL cData
|
||||
|
||||
? "MsgBox:", hb_dynCall( { "MessageBoxA", "user32.dll" }, 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )
|
||||
|
||||
IF hb_FileExists( "libcurl.dll" )
|
||||
hLib := hb_LibLoad( "libcurl.dll" )
|
||||
? hb_dynCall( { "curl_version", hLib, HB_DYN_CTYPE_CHAR_PTR } )
|
||||
hb_LibFree( hLib )
|
||||
? hb_dynCall( { "curl_version", "libcurl.dll", HB_DYN_CTYPE_CHAR_PTR } )
|
||||
ENDIF
|
||||
|
||||
/* Force Windows not to show dragged windows contents */
|
||||
|
||||
#define SPI_SETDRAGFULLWINDOWS 37
|
||||
|
||||
? "Full content drag: OFF"
|
||||
? hb_dynCall( { "SystemParametersInfo", "user32.dll" }, SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
? "Full content drag: ON"
|
||||
? hb_dynCall( { "SystemParametersInfo", "user32.dll" }, SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
/* Get some standard Windows folders */
|
||||
|
||||
hLib := hb_LibLoad( "shell32.dll" )
|
||||
? "ValType( hLib ): ", ValType( hLib )
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL (BOOL retval): ", hb_dynCall( { "SHGetSpecialFolderPathA", hLib, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL (BOOL retval): ", hb_dynCall( { GetProcAddress( hLib, "SHGetSpecialFolderPathA" ), HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathA", hLib }, 0, CSIDL_ADMINTOOLS, 0, 0, cData ) // WRONG
|
||||
? "cData:", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL (PARAMS): ", hb_dynCall( { "SHGetSpecialFolderPathA", hLib, NIL, NIL, NIL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathA", hLib }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathW", hLib }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "cData BEFORE: ", cData
|
||||
? "HB_DYNCALL (MISSING @1): ", hb_dynCall( { "SHGetFolderPathA", hLib }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
|
||||
? "cData AFTER: ", cData
|
||||
? "------"
|
||||
hb_LibFree( hLib )
|
||||
|
||||
RETURN
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DLL call test.
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#define _ISOK_( a, b ) iif( a == b, "OK", "WRONG" )
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cFileName
|
||||
LOCAL a, b
|
||||
|
||||
#if defined( __ARCH64BIT__ )
|
||||
cFileName := "test_x64.dll"
|
||||
#else
|
||||
cFileName := "test_x86.dll"
|
||||
#endif
|
||||
|
||||
? "-", cFileName
|
||||
a := 567.89 ; ? ">", a, b := win_dllCall( { "TESTD" , cFileName, hb_bitOr( HB_DYN_CTYPE_DOUBLE , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_DOUBLE }, a ), _ISOK_( a, b )
|
||||
a := 567.89 ; ? ">", a, b := win_dllCall( { "TESTF" , cFileName, hb_bitOr( HB_DYN_CTYPE_FLOAT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_FLOAT }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 7 ) ; ? ">", a, b := win_dllCall( { "TESTC" , cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 8 ) - 1 ; ? ">", a, b := win_dllCall( { "TESTUC", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 15 ) ; ? ">", a, b := win_dllCall( { "TESTS" , cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 16 ) - 1 ; ? ">", a, b := win_dllCall( { "TESTUS", cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 31 ) ; ? ">", a, b := win_dllCall( { "TESTI" , cFileName, hb_bitOr( HB_DYN_CTYPE_INT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := win_dllCall( { "TESTUI", cFileName, hb_bitOr( HB_DYN_CTYPE_INT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 31 ) ; ? ">", a, b := win_dllCall( { "TESTL" , cFileName, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := win_dllCall( { "TESTUL", cFileName, hb_bitOr( HB_DYN_CTYPE_LONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 63 ) ; ? ">", a, b := win_dllCall( { "TEST6" , cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG }, a ), _ISOK_( a, b )
|
||||
a := 18446744073709600000 ; ? ">", a, b := win_dllCall( { "TESTU6", cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := "hello world!" ; ? ">", a, b := win_dllCall( { "TESTST", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL ) }, a ), _ISOK_( a, b )
|
||||
? "=="
|
||||
|
||||
a := "hello world!" ; ? ">", a, win_dllCall( { "TESTST", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL, HB_DYN_ENC_RAW ), hb_bitOr( HB_DYN_CTYPE_CHAR_PTR, HB_DYN_ENC_RAW ) }, a )
|
||||
a := "hello world!" ; ? ">", a, win_dllCallFoxPro( "DECLARE STRING TESTST IN " + cFileName + " STRING", a )
|
||||
|
||||
RETURN
|
||||
@@ -303,56 +303,3 @@ HB_FUNC( WIN_SYSREFRESH )
|
||||
CloseHandle( hDummyEvent );
|
||||
hb_retni( 0 );
|
||||
}
|
||||
|
||||
FARPROC hbwin_getprocaddress( HMODULE hDLL, PHB_ITEM pParam, HB_BOOL * pbWIDE )
|
||||
{
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
void * hStr;
|
||||
HB_SIZE nLen;
|
||||
LPCWSTR szProc = hb_itemGetStrU16( pParam, HB_CDP_ENDIAN_NATIVE, &hStr, &nLen );
|
||||
FARPROC lpFunction = GetProcAddress( hDLL, szProc ? szProc :
|
||||
( LPCWSTR ) ( HB_PTRDIFF ) ( hb_itemGetNI( pParam ) & 0x0FFFF ) );
|
||||
|
||||
if( ! lpFunction && szProc ) /* try with WIDE suffix? */
|
||||
{
|
||||
LPWSTR pszProcW = ( LPWSTR ) hb_xgrab( ( nLen + 2 ) * sizeof( WCHAR ) );
|
||||
memcpy( pszProcW, szProc, nLen * sizeof( WCHAR ) );
|
||||
pszProcW[ nLen++ ] = L'W';
|
||||
pszProcW[ nLen++ ] = 0;
|
||||
lpFunction = GetProcAddress( hDLL, pszProcW );
|
||||
hb_xfree( pszProcW );
|
||||
}
|
||||
hb_strfree( hStr );
|
||||
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_TRUE;
|
||||
#else
|
||||
const char * szProc = hb_itemGetCPtr( pParam );
|
||||
FARPROC lpFunction = GetProcAddress( hDLL, szProc ? szProc :
|
||||
( LPCSTR ) ( HB_PTRDIFF ) ( hb_itemGetNI( pParam ) & 0x0FFFF ) );
|
||||
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_FALSE;
|
||||
|
||||
#if defined( UNICODE )
|
||||
if( ! lpFunction && szProc ) /* try with WIDE suffix? */
|
||||
{
|
||||
char * pszFuncName = hb_xstrcpy( NULL, szProc, "W", NULL );
|
||||
lpFunction = GetProcAddress( hDLL, pszFuncName );
|
||||
hb_xfree( pszFuncName );
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ! lpFunction && szProc ) /* try with ANSI suffix? */
|
||||
{
|
||||
char * pszFuncName = hb_xstrcpy( NULL, szProc, "A", NULL );
|
||||
lpFunction = GetProcAddress( hDLL, pszFuncName );
|
||||
hb_xfree( pszFuncName );
|
||||
if( pbWIDE )
|
||||
*pbWIDE = HB_FALSE;
|
||||
}
|
||||
#endif
|
||||
return lpFunction;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ PRG_SOURCES := \
|
||||
dbgfx.prg \
|
||||
decode.prg \
|
||||
dirrec.prg \
|
||||
diskhb.prg \
|
||||
dumpvar.prg \
|
||||
hblog.prg \
|
||||
hblognet.prg \
|
||||
|
||||
@@ -38,9 +38,5 @@ PRG_HEADERS := \
|
||||
dll.ch \
|
||||
xpp.ch \
|
||||
|
||||
ifneq ($(filter $(HB_PLATFORM),win wce),)
|
||||
HB_INC_DEPEND := -I$(TOP)$(ROOT)contrib/hbwin
|
||||
endif
|
||||
|
||||
include $(TOP)$(ROOT)config/header.mk
|
||||
include $(TOP)$(ROOT)config/lib.mk
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Windows DLL handling function (Xbase++ compatible)
|
||||
* Dynamic library handling functions (Xbase++ compatible)
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* Copyright 2006 Paul Tucker <ptucker@sympatico.ca>
|
||||
@@ -56,10 +56,7 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
#include "hbwin.h"
|
||||
#include "hbdyn.h"
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#include "dll.ch"
|
||||
|
||||
@@ -221,13 +218,3 @@ HB_FUNC( DLLEXECUTECALL )
|
||||
2,
|
||||
NULL );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
HB_FUNC( DLLLOAD ) { hb_retnint( 0 ); }
|
||||
HB_FUNC( DLLUNLOAD ) { hb_retl( HB_FALSE ); }
|
||||
HB_FUNC( DLLCALL ) {}
|
||||
HB_FUNC( DLLPREPARECALL ) {}
|
||||
HB_FUNC( DLLEXECUTECALL ) {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DLL call demonstration.
|
||||
@@ -13,33 +11,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define MB_OK 0x00000000
|
||||
#define MB_OKCANCEL 0x00000001
|
||||
#define MB_ABORTRETRYIGNORE 0x00000002
|
||||
#define MB_YESNOCANCEL 0x00000003
|
||||
#define MB_YESNO 0x00000004
|
||||
#define MB_RETRYCANCEL 0x00000005
|
||||
#define MB_CANCELTRYCONTINUE 0x00000006
|
||||
#define MB_ICONHAND 0x00000010
|
||||
#define MB_ICONQUESTION 0x00000020
|
||||
#define MB_ICONEXCLAMATION 0x00000030
|
||||
#define MB_ICONASTERISK 0x00000040
|
||||
#define MB_USERICON 0x00000080
|
||||
#define MB_DEFBUTTON2 0x00000100
|
||||
#define MB_DEFBUTTON3 0x00000200
|
||||
#define MB_DEFBUTTON4 0x00000300
|
||||
#define MB_SYSTEMMODAL 0x00001000
|
||||
#define MB_TASKMODAL 0x00002000
|
||||
#define MB_HELP 0x00004000
|
||||
#define MB_NOFOCUS 0x00008000
|
||||
#define MB_SETFOREGROUND 0x00010000
|
||||
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000
|
||||
#define MB_TOPMOST 0x00040000
|
||||
#define MB_RIGHT 0x00080000
|
||||
#define MB_RTLREADING 0x00100000
|
||||
#include "simpleio.ch"
|
||||
|
||||
#define CSIDL_APPDATA 0x001a /* <username>\Application Data */
|
||||
#define CSIDL_ADMINTOOLS 0x0030 /* <username>\Start Menu\Programs\Administrative Tools */
|
||||
#include "dll.ch"
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
@@ -47,17 +21,19 @@ PROCEDURE Main()
|
||||
LOCAL hDLL
|
||||
LOCAL cData
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
|
||||
IF hb_FileExists( "pscript.dll" )
|
||||
hDLL := DllLoad( "pscript.dll" )
|
||||
cData := Space( 24 )
|
||||
DllCall( hDll, NIL, "PSGetVersion", @cData )
|
||||
DllCall( hDll, DLL_OSAPI, "PSGetVersion", @cData )
|
||||
? ">" + cData + "<"
|
||||
DllUnload( hDLL )
|
||||
|
||||
// ; Testing failure 1
|
||||
hDLL := DllLoad( "pscript.dll" )
|
||||
cData := Space( 24 )
|
||||
DllCall( hDll, NIL, "PSGet__Version", @cData )
|
||||
DllCall( hDll, DLL_OSAPI, "PSGet__Version", @cData )
|
||||
? ">" + cData + "<"
|
||||
DllUnload( hDLL )
|
||||
ENDIF
|
||||
@@ -69,28 +45,58 @@ PROCEDURE Main()
|
||||
? cData
|
||||
DllUnload( hDLL )
|
||||
|
||||
? "MsgBox:", DllCall( "user32.dll", NIL, "MessageBoxA", 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )
|
||||
#define MB_OK 0x00000000
|
||||
#define MB_OKCANCEL 0x00000001
|
||||
#define MB_ABORTRETRYIGNORE 0x00000002
|
||||
#define MB_YESNOCANCEL 0x00000003
|
||||
#define MB_YESNO 0x00000004
|
||||
#define MB_RETRYCANCEL 0x00000005
|
||||
#define MB_CANCELTRYCONTINUE 0x00000006
|
||||
#define MB_ICONHAND 0x00000010
|
||||
#define MB_ICONQUESTION 0x00000020
|
||||
#define MB_ICONEXCLAMATION 0x00000030
|
||||
#define MB_ICONASTERISK 0x00000040
|
||||
#define MB_USERICON 0x00000080
|
||||
#define MB_DEFBUTTON2 0x00000100
|
||||
#define MB_DEFBUTTON3 0x00000200
|
||||
#define MB_DEFBUTTON4 0x00000300
|
||||
#define MB_SYSTEMMODAL 0x00001000
|
||||
#define MB_TASKMODAL 0x00002000
|
||||
#define MB_HELP 0x00004000
|
||||
#define MB_NOFOCUS 0x00008000
|
||||
#define MB_SETFOREGROUND 0x00010000
|
||||
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000
|
||||
#define MB_TOPMOST 0x00040000
|
||||
#define MB_RIGHT 0x00080000
|
||||
#define MB_RTLREADING 0x00100000
|
||||
|
||||
? "MsgBox:", DllCall( "user32.dll", DLL_OSAPI, "MessageBoxA", 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )
|
||||
|
||||
/* Force Windows not to show dragged windows contents */
|
||||
|
||||
#define SPI_SETDRAGFULLWINDOWS 37
|
||||
|
||||
? "Full content drag: OFF"
|
||||
? DllCall( "user32.dll", NIL, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
|
||||
? DllCall( "user32.dll", DLL_OSAPI, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
? "Full content drag: ON"
|
||||
? DllCall( "user32.dll", NIL, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
|
||||
? DllCall( "user32.dll", DLL_OSAPI, "SystemParametersInfoA", SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
#define CSIDL_APPDATA 0x001a /* <username>\Application Data */
|
||||
#define CSIDL_ADMINTOOLS 0x0030 /* <username>\Start Menu\Programs\Administrative Tools */
|
||||
|
||||
? "DLLCALL"
|
||||
cData := Space( MAX_PATH )
|
||||
? DllCall( "shell32.dll", NIL, "SHGetFolderPathA", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? DllCall( "shell32.dll", DLL_OSAPI, "SHGetFolderPathA", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "REF:", cData
|
||||
|
||||
? "DLLCALL"
|
||||
cData := Space( MAX_PATH )
|
||||
? DllCall( "shell32.dll", NIL, "SHGetFolderPathW", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? DllCall( "shell32.dll", DLL_OSAPI, "SHGetFolderPathW", 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "REF:", cData
|
||||
|
||||
#endif
|
||||
|
||||
RETURN
|
||||
|
||||
@@ -5,4 +5,3 @@
|
||||
incpaths=.
|
||||
|
||||
libs=xpp
|
||||
{win}libs=hbwin
|
||||
|
||||
@@ -89,6 +89,7 @@ PRG_HEADERS := \
|
||||
getexit.ch \
|
||||
hbclass.ch \
|
||||
hbdebug.ch \
|
||||
hbdyn.ch \
|
||||
hbextcdp.ch \
|
||||
hbextlng.ch \
|
||||
hbextern.ch \
|
||||
|
||||
@@ -1111,6 +1111,8 @@ extern HB_EXPORT HB_BOOL hb_libFree( PHB_ITEM pDynLib );
|
||||
extern HB_EXPORT void * hb_libHandle( PHB_ITEM pDynLib );
|
||||
extern HB_EXPORT void * hb_libSymAddr( PHB_ITEM pDynLib, const char * pszSymbol );
|
||||
|
||||
extern HB_EXPORT void hb_dynCall( int iFuncFlags, void * pFunction, int iParams, int iFirst, int * piArgFlags );
|
||||
|
||||
/* misc */
|
||||
extern HB_EXPORT const char * hb_verCPU( void ); /* retrieves a constant string with CPU architecture */
|
||||
extern HB_EXPORT char * hb_verPlatform( void ); /* retrieves a newly allocated buffer containing platform version */
|
||||
|
||||
@@ -56,8 +56,8 @@
|
||||
#define HBDYN_CH_
|
||||
|
||||
/* C calling conventions */
|
||||
#define HB_DYN_CALLCONV_STDCALL 0x000000 /* Windows API default */
|
||||
#define HB_DYN_CALLCONV_CDECL 0x100000 /* C default */
|
||||
#define HB_DYN_CALLCONV_CDECL 0x000000 /* C default */
|
||||
#define HB_DYN_CALLCONV_STDCALL 0x100000 /* Windows API default */
|
||||
#define HB_DYN_CALLCONV_SYSCALL 0x200000 /* OS/2 32-bit default. */
|
||||
|
||||
/* String encodings */
|
||||
@@ -74,6 +74,8 @@ C_SOURCES := \
|
||||
hbbit.c \
|
||||
hbbyte.c \
|
||||
hbcrc.c \
|
||||
hbdyn.c \
|
||||
hbdynhb.c \
|
||||
hbhex.c \
|
||||
hbfeof.c \
|
||||
hbmd5.c \
|
||||
|
||||
@@ -145,38 +145,9 @@ HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char *
|
||||
pszName[ 0 ] = '\0';
|
||||
|
||||
if( pszDir && pszDir[ 0 ] != '\0' )
|
||||
{
|
||||
hb_strncpy( pszName, pszDir, HB_PATH_MAX - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
TCHAR lpName[ HB_PATH_MAX ];
|
||||
|
||||
if( GetTempPath( HB_PATH_MAX, lpName ) )
|
||||
HB_TCHAR_GETFROM( pszName, lpName, HB_PATH_MAX );
|
||||
else
|
||||
{
|
||||
pszName[ 0 ] = '.';
|
||||
pszName[ 1 ] = '\0';
|
||||
}
|
||||
#else
|
||||
char * pszTmpDir = hb_getenv( "TMPDIR" );
|
||||
|
||||
if( !fsGetTempDirByCase( pszName, pszTmpDir ) )
|
||||
{
|
||||
#ifdef P_tmpdir
|
||||
if( !fsGetTempDirByCase( pszName, P_tmpdir ) )
|
||||
#endif
|
||||
{
|
||||
pszName[ 0 ] = '.';
|
||||
pszName[ 1 ] = '\0';
|
||||
}
|
||||
}
|
||||
if( pszTmpDir )
|
||||
hb_xfree( pszTmpDir );
|
||||
#endif
|
||||
}
|
||||
hb_fsTempDir( pszName );
|
||||
|
||||
if( pszName[ 0 ] != '\0' )
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#include "hbset.h"
|
||||
#include "hbstack.h"
|
||||
|
||||
#include "hbdyn.h"
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#define _MASK_CALLCONV 0xF00000
|
||||
#define _MASK_ENCODING 0x0F0000
|
||||
@@ -52,13 +52,14 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbdyn.h"
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
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;
|
||||
int iFuncFlags = HB_DYN_CALLCONV_CDECL;
|
||||
|
||||
PHB_ITEM pLibraryHandle = NULL;
|
||||
HB_BOOL bFreeLibrary = HB_FALSE;
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DLL call test.
|
||||
* Dynamic library call test.
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
@@ -12,22 +12,22 @@
|
||||
*/
|
||||
|
||||
/* Build with:
|
||||
hbmk2 -hbdyn testdll.c -otest_x86
|
||||
hbmk2 -hbdyn testdll.c -otest_x64
|
||||
hbmk2 -hbdyn testdyn.c -otest_x86
|
||||
hbmk2 -hbdyn testdyn.c -otest_x64
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
HB_EXPORT double TESTD ( double value ) { printf( "DLL: %lf\n" , value ); return value; }
|
||||
HB_EXPORT float TESTF ( float value ) { printf( "DLL: %f\n" , value ); return value; }
|
||||
HB_EXPORT char TESTC ( char value ) { printf( "DLL: %d\n" , value ); return value; }
|
||||
HB_EXPORT unsigned char TESTUC( unsigned char value ) { printf( "DLL: %d\n" , value ); return value; }
|
||||
HB_EXPORT short TESTS ( short value ) { printf( "DLL: %hd\n" , value ); return value; }
|
||||
HB_EXPORT unsigned short TESTUS( unsigned short value ) { printf( "DLL: %hu\n" , value ); return value; }
|
||||
HB_EXPORT int TESTI ( int value ) { printf( "DLL: %d\n" , value ); return value; }
|
||||
HB_EXPORT unsigned int TESTUI( unsigned int value ) { printf( "DLL: %u\n" , value ); return value; }
|
||||
HB_EXPORT long TESTL ( long value ) { printf( "DLL: %ld\n" , value ); return value; }
|
||||
HB_EXPORT unsigned long TESTUL( unsigned long value ) { printf( "DLL: %lu\n" , value ); return value; }
|
||||
HB_EXPORT HB_LONGLONG TEST6 ( HB_LONGLONG value ) { printf( "DLL: %"PFLL"d\n" , value ); return value; }
|
||||
HB_EXPORT HB_ULONGLONG TESTU6( HB_ULONGLONG value ) { printf( "DLL: %"PFLL"u\n" , value ); return value; }
|
||||
HB_EXPORT char * TESTST( char * value ) { printf( "DLL: %s\n" , value ); return value; }
|
||||
HB_EXPORT double TESTD ( double value ) { printf( "DYN: %lf\n" , value ); return value; }
|
||||
HB_EXPORT float TESTF ( float value ) { printf( "DYN: %f\n" , value ); return value; }
|
||||
HB_EXPORT char TESTC ( char value ) { printf( "DYN: %d\n" , value ); return value; }
|
||||
HB_EXPORT unsigned char TESTUC( unsigned char value ) { printf( "DYN: %d\n" , value ); return value; }
|
||||
HB_EXPORT short TESTS ( short value ) { printf( "DYN: %hd\n" , value ); return value; }
|
||||
HB_EXPORT unsigned short TESTUS( unsigned short value ) { printf( "DYN: %hu\n" , value ); return value; }
|
||||
HB_EXPORT int TESTI ( int value ) { printf( "DYN: %d\n" , value ); return value; }
|
||||
HB_EXPORT unsigned int TESTUI( unsigned int value ) { printf( "DYN: %u\n" , value ); return value; }
|
||||
HB_EXPORT long TESTL ( long value ) { printf( "DYN: %ld\n" , value ); return value; }
|
||||
HB_EXPORT unsigned long TESTUL( unsigned long value ) { printf( "DYN: %lu\n" , value ); return value; }
|
||||
HB_EXPORT HB_LONGLONG TEST6 ( HB_LONGLONG value ) { printf( "DYN: %"PFLL"d\n" , value ); return value; }
|
||||
HB_EXPORT HB_ULONGLONG TESTU6( HB_ULONGLONG value ) { printf( "DYN: %"PFLL"u\n" , value ); return value; }
|
||||
HB_EXPORT char * TESTST( char * value ) { printf( "DYN: %s\n" , value ); return value; }
|
||||
108
harbour/tests/testdyn.prg
Normal file
108
harbour/tests/testdyn.prg
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Dynamic library call demonstration. (on Windows)
|
||||
*
|
||||
* Copyright 2008 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL hLib
|
||||
LOCAL cData
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
|
||||
#define MB_OK 0x00000000
|
||||
#define MB_OKCANCEL 0x00000001
|
||||
#define MB_ABORTRETRYIGNORE 0x00000002
|
||||
#define MB_YESNOCANCEL 0x00000003
|
||||
#define MB_YESNO 0x00000004
|
||||
#define MB_RETRYCANCEL 0x00000005
|
||||
#define MB_CANCELTRYCONTINUE 0x00000006
|
||||
#define MB_ICONHAND 0x00000010
|
||||
#define MB_ICONQUESTION 0x00000020
|
||||
#define MB_ICONEXCLAMATION 0x00000030
|
||||
#define MB_ICONASTERISK 0x00000040
|
||||
#define MB_USERICON 0x00000080
|
||||
#define MB_DEFBUTTON2 0x00000100
|
||||
#define MB_DEFBUTTON3 0x00000200
|
||||
#define MB_DEFBUTTON4 0x00000300
|
||||
#define MB_SYSTEMMODAL 0x00001000
|
||||
#define MB_TASKMODAL 0x00002000
|
||||
#define MB_HELP 0x00004000
|
||||
#define MB_NOFOCUS 0x00008000
|
||||
#define MB_SETFOREGROUND 0x00010000
|
||||
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000
|
||||
#define MB_TOPMOST 0x00040000
|
||||
#define MB_RIGHT 0x00080000
|
||||
#define MB_RTLREADING 0x00100000
|
||||
|
||||
? "MsgBox:", hb_dynCall( { "MessageBoxA", "user32.dll", HB_DYN_CALLCONV_STDCALL }, 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )
|
||||
|
||||
IF hb_FileExists( "libcurl.dll" )
|
||||
hLib := hb_LibLoad( "libcurl.dll" )
|
||||
? hb_dynCall( { "curl_version", hLib, HB_DYN_CTYPE_CHAR_PTR } )
|
||||
hb_LibFree( hLib )
|
||||
? hb_dynCall( { "curl_version", "libcurl.dll", HB_DYN_CTYPE_CHAR_PTR } )
|
||||
ENDIF
|
||||
|
||||
/* Force Windows not to show dragged windows contents */
|
||||
|
||||
#define SPI_SETDRAGFULLWINDOWS 37
|
||||
|
||||
? "Full content drag: OFF"
|
||||
? hb_dynCall( { "SystemParametersInfo", "user32.dll", HB_DYN_CALLCONV_STDCALL }, SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
? "Full content drag: ON"
|
||||
? hb_dynCall( { "SystemParametersInfo", "user32.dll", HB_DYN_CALLCONV_STDCALL }, SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
|
||||
Inkey( 0 )
|
||||
|
||||
/* Get some standard Windows folders */
|
||||
|
||||
#define CSIDL_APPDATA 0x001a /* <username>\Application Data */
|
||||
#define CSIDL_ADMINTOOLS 0x0030 /* <username>\Start Menu\Programs\Administrative Tools */
|
||||
|
||||
hLib := hb_LibLoad( "shell32.dll" )
|
||||
? "ValType( hLib ): ", ValType( hLib )
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL (BOOL retval): ", hb_dynCall( { "SHGetSpecialFolderPathA", hLib, hb_bitOr( HB_DYN_CALLCONV_STDCALL, HB_DYN_CTYPE_BOOL ) }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData ) // WRONG
|
||||
? "cData:", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL (PARAMS): ", hb_dynCall( { "SHGetSpecialFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL, NIL, NIL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "HB_DYNCALL: ", hb_dynCall( { "SHGetFolderPathW", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
|
||||
? "@cData: ", cData
|
||||
? "------"
|
||||
cData := Space( MAX_PATH )
|
||||
? "cData BEFORE: ", cData
|
||||
? "HB_DYNCALL (MISSING @1): ", hb_dynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
|
||||
? "cData AFTER: ", cData
|
||||
? "------"
|
||||
hb_LibFree( hLib )
|
||||
|
||||
#endif
|
||||
|
||||
RETURN
|
||||
49
harbour/tests/testdyn1.prg
Normal file
49
harbour/tests/testdyn1.prg
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Dynamic library call test.
|
||||
*
|
||||
* Copyright 2010 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "simpleio.ch"
|
||||
|
||||
#include "hbdyn.ch"
|
||||
|
||||
#define _ISOK_( a, b ) iif( a == b, "OK", "WRONG" )
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cFileName
|
||||
LOCAL a, b
|
||||
|
||||
#if defined( __ARCH64BIT__ )
|
||||
cFileName := "test_x64.dll"
|
||||
#else
|
||||
cFileName := "test_x86.dll"
|
||||
#endif
|
||||
|
||||
? "-", cFileName
|
||||
a := 567.89 ; ? ">", a, b := hb_dynCall( { "TESTD" , cFileName, hb_bitOr( HB_DYN_CTYPE_DOUBLE , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_DOUBLE }, a ), _ISOK_( a, b )
|
||||
a := 567.89 ; ? ">", a, b := hb_dynCall( { "TESTF" , cFileName, hb_bitOr( HB_DYN_CTYPE_FLOAT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_FLOAT }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 7 ) ; ? ">", a, b := hb_dynCall( { "TESTC" , cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 8 ) - 1 ; ? ">", a, b := hb_dynCall( { "TESTUC", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 15 ) ; ? ">", a, b := hb_dynCall( { "TESTS" , cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 16 ) - 1 ; ? ">", a, b := hb_dynCall( { "TESTUS", cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 31 ) ; ? ">", a, b := hb_dynCall( { "TESTI" , cFileName, hb_bitOr( HB_DYN_CTYPE_INT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := hb_dynCall( { "TESTUI", cFileName, hb_bitOr( HB_DYN_CTYPE_INT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 31 ) ; ? ">", a, b := hb_dynCall( { "TESTL" , cFileName, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG }, a ), _ISOK_( a, b )
|
||||
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := hb_dynCall( { "TESTUL", cFileName, hb_bitOr( HB_DYN_CTYPE_LONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := -( 2 ^ 63 ) ; ? ">", a, b := hb_dynCall( { "TEST6" , cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG }, a ), _ISOK_( a, b )
|
||||
a := 18446744073709600000 ; ? ">", a, b := hb_dynCall( { "TESTU6", cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG_UNSIGNED }, a ), _ISOK_( a, b )
|
||||
a := "hello world!" ; ? ">", a, b := hb_dynCall( { "TESTST", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL ) }, a ), _ISOK_( a, b )
|
||||
? "=="
|
||||
|
||||
a := "hello world!" ; ? ">", a, hb_dynCall( { "TESTST", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL, HB_DYN_ENC_RAW ), hb_bitOr( HB_DYN_CTYPE_CHAR_PTR, HB_DYN_ENC_RAW ) }, a )
|
||||
// a := "hello world!" ; ? ">", a, hb_dynCallFoxPro( "DECLARE STRING TESTST IN " + cFileName + " STRING", a )
|
||||
|
||||
RETURN
|
||||
Reference in New Issue
Block a user