by don lowenstein » Sat Jan 06, 2018 4:08 pm
Here is the "calling program" = babu.prg modified
After that is the "dll program" = babudll.prg modified
you may want to remove the altd() breaks and the reference to the external debugging libraries.
REQUEST HB_GT_WIN
REQUEST HB_GT_WIN_DEFAULT
*********************************************************
// Using Harbour DLLs
// To build BabuDLL.dll do: buildhd.bat DLL-DON
#include "FiveWin.ch"
static hDLL
REQUEST HB_GT_WIN
REQUEST HB_GT_WIN_DEFAULT
// Harbour requirement for console debug mode comment out for Production Make/Link
// comment out this procedure for prod
procedure hb_gt_gui_default
return
*****************************************************
function Main()
// local hItem1 := ItemNew( "Hello world!-billy/don" )
// local hItem2 := ItemNew( "From a Harbour DLL-billy/don" )
local hItem1
local hItem2
local marray := {}
local i, OPRINTER
local ownd, OWAITDLG , ODIALOG, WORKTEXT, OSAY, MDLL
altd(1)
altd()
hDLL = LoadLibrary( "DLL-DON2.DLL" )
SET RESOURCES TO
DEFINE DIALOG owaitdlg FROM 1, 1 TO 222, 333 ;
STYLE nOR( WS_VISIBLE, WS_POPUP ) PIXEL
OWAITDLG:CTITLE := 'Prepare System Parameters'
worktext := ''
WORKTEXT += CR_LF()
WORKTEXT += 'Retrieving System Import' + CR_LF()
WORKTEXT += CR_LF()
WORKTEXT += 'and Upload Parameters' + CR_LF()
WORKTEXT += CR_LF()
WORKTEXT += 'This may Take Several Seconds' + CR_LF()
WORKTEXT += CR_LF()
WORKTEXT += 'Please Wait' + CR_LF()
@ 10, 20 SAY OSAY VAR WORKTEXT ;
OF OWAITDLG
ACTIVATE DIALOG OWAITDLG ;
CENTERED ;
NOWAIT
// pass the window/osay hwnd
hitem1 := ItemNew( owaitdlg:hwnd )
hitem2 := ItemNew( OSAY:hwnd )
HbDLLEntry2( "TEST3", hItem1, hitem2 )
// pass the dialog
//hitem1 := ItemNew( owaitdlg )
//hitem2 := ItemNew( OSAY:hwnd )
//HbDLLEntry2( "TEST3", hItem1, hitem2 )
ItemRelease( hItem1 )
ItemRelease( hItem2 )
FreeLibrary( hDLL )
return nil
***********
FUNCTION CR_LF()
RETURN CHR(13) + chr(10)
*************
****************************************
DLL FUNCTION HBDLLENTRY( cProc AS LPSTR ) AS LONG PASCAL LIB hDLL
DLL FUNCTION HBDLLENTRY2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LONG PASCAL LIB hDLL
// DLL FUNCTION HBDLLENTRY3( cProc AS LPSTR, pItem1 AS PTR, pItem2 AS PTR ) AS LONG PASCAL LIB hDLL
#pragma BEGINDUMP
#include <hbapi.h>
#include <hbapiitm.h>
HB_FUNC( ITEMNEW )
{
hb_retnl( ( unsigned long ) hb_itemNew( hb_param( 1, HB_IT_ANY ) ) );
}
HB_FUNC( ITEMRELEASE )
{
hb_retl( hb_itemRelease( ( PHB_ITEM ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMP
************************************************************
************************************************************
"dll program"
// To build BabuDLL.dll do: buildhd.bat babuDLL
// To run this DLL, do buidh.bat dll-don2.prg
REQUEST HB_GT_WIN
REQUEST HB_GT_WIN_DEFAULT
// Harbour requirement for console debug mode comment out for Production Make/Link
// comment out this procedure for prod
procedure hb_gt_gui_default
return
***************************************************************
function Test()
MsgInfo( "Hello from inside the DLL!", 'our message 1' )
return nil
********************************************************************
function Test2( cMsg1, cMsg2 )
MsgInfo( cMsg1, cMsg2, 'our message 2' )
return nil
**************************************************************
function Test3( VAL1, VAL2 )
local a, b, c, d, e, f
local hwnd := val1
altd(1)
altd()
a := val2
b := a
altd(1)
altd()
c := d
altd(1)
altd()
// Function oWndFromHwnd( hWnd ) --> oWnd
b := oWndFromHwnd( hWnd )
return nil
****************************************************
#pragma BEGINDUMP
#include <windows.h>
#include <hbvm.h>
#include <hbapiitm.h>
BOOL WINAPI DllEntryPoint( HINSTANCE hinstDLL, DWORD fdwReason,
LPVOID lpvReserved )
{
HB_SYMBOL_UNUSED( hinstDLL );
HB_SYMBOL_UNUSED( fdwReason );
HB_SYMBOL_UNUSED( lpvReserved );
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
// MessageBox( 0, "DLL properly loaded -", "DLL entry", 0 );
hb_vmInit( 0 );
break;
case DLL_PROCESS_DETACH:
// MessageBox( 0, "DLL unloaded - ", "DLL exit", 0 );
break;
}
return TRUE;
}
void pascal __export HBDLLENTRY( char * cProcName )
{
hb_itemDoC( cProcName, 0 );
}
void pascal __export HBDLLENTRY2( char * cProcName, PHB_ITEM pParam1, PHB_ITEM pParam2 )
{
hb_itemDoC( cProcName, 2, pParam1, pParam2 );
}
#pragma ENDDUMP
********************************************