HB_EXPORT LONG PASCAL HBDLLENTRY( char * cProcName )
{
hb_itemDoC( cProcName, 0, 0 );
return 0;
}
HB_EXPORT LONG PASCAL HBDLLENTRY1( char * cProcName, LONG pItem )
{
hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
return 0;
}
HB_EXPORT LONG PASCAL HBDLLENTRY2( char * cProcName, LONG pItem1, LONG pItem2 )
{
hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
return 0;
}
with the folowing three lines of text:Harbour Exception window
CALLED FROM CALLDLL(0)
CALLED FROM HBDLLENTRY1( 18 )
CALLED FROM MAIN(12)
//----------------------------------------------------------------------------//
function Main()
MsgInfo( "Inside DLL main()" )
return nil
//----------------------------------------------------------------------------//
function OneParam( x )
MsgInfo( x )
return nil
//----------------------------------------------------------------------------//
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <hbapiitm.h>
__declspec( dllexport ) LONG pascal DOPROC( char * cProcName, char * cParam )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!!
if( cProcName )
{
hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
hb_itemRelease( pItem );
}
else
MessageBox( 0, "inside the DLL", "DOPROC", 0 );
return 0;
}
#pragma ENDDUMP
//----------------------------------------------------------------------------//
#include "FiveWin.ch"
function Main()
local cString := "Hello world!"
DOPROC( "ONEPARAM", cString )
MsgInfo( "ok from EXE" )
return nil
DLL FUNCTION DOPROC( cProc AS LPSTR, cText AS LPSTR ) AS LONG PASCAL LIB "MYDLL.dll"
#include <windows.h>
typedef long pascal ( * DOPROC ) ( char * cProcName, char * cString );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
HINSTANCE hDLL = LoadLibrary( "MyDLL.DLL" );
DOPROC pDoProc = ( DOPROC ) GetProcAddress( hDLL, "DOPROC" );
pDoProc( "ONEPARAM", "Hello world!" );
MessageBox( 0, "back in C EXE", "ok", 0 );
FreeLibrary( hDLL );
return 0;
}
//5th July 2008. Testing User Defined DLL entry points into FWH
//----------------------------------------------------------------------------//
function Main()
MsgInfo( "Inside DLL main()" )
return nil
//----------------------------------------------------------------------------//
function OneParam( x )
MsgInfo( x )
return nil
function TwoParam( x , y)
MsgInfo( x )
MsgInfo( y )
return nil
function ThreeParam( cx, cy, nz)
MsgInfo( cx )
MsgInfo( cy )
MsgInfo( nz + 6)
MsgInfo( valtype(nz))
return nil
//----------------------------------------------------------------------------//
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <hbapiitm.h>
__declspec( dllexport ) LONG pascal DOPROC( char * cProcName, char * cParam )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!!
if( cProcName )
{
hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
hb_itemRelease( pItem );
}
else
MessageBox( 0, "inside the DLL ... One Parameter", "DOPROC", 0 );
return 0;
}
__declspec( dllexport ) LONG pascal DOPROC_2( char * cProcName, char * cParam, char * cParam_2 )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!! 1st Parameter ... String
PHB_ITEM pItem_2 = hb_itemPutC( NULL, cParam_2 ); // Harbour builds the item !!! 2nd parameter ... String
if( cProcName )
{
hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem, ( PHB_ITEM ) pItem_2, 0 );
hb_itemRelease( pItem );
hb_itemRelease( pItem_2);
}
else
MessageBox( 0, "inside the DLL ... Two Parameters", "DOPROC_2", 0 );
return 0;
}
__declspec( dllexport ) LONG pascal DOPROC_3( char * cProcName, char * cParam, char * cParam_2, int nParam_3 )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!! 1st Parameter ... String
PHB_ITEM pItem_2 = hb_itemPutC( NULL, cParam_2 ); // Harbour builds the item !!! 2nd parameter ... String
PHB_ITEM pItem_3 = hb_itemPutNI( NULL, nParam_3 ); // Harbour builds the item !!! 3rd parameter ... Integer
if( cProcName )
{
hb_itemDoC( cProcName, 3, ( PHB_ITEM ) pItem, ( PHB_ITEM ) pItem_2, ( PHB_ITEM ) pItem_3, 0 );
hb_itemRelease( pItem );
hb_itemRelease( pItem_2 );
hb_itemRelease( pItem_3 );
}
else
MessageBox( 0, "inside the DLL ... Three Parameters (2 strings, 1 integer)", "DOPROC_3", 0 );
return 0;
}
#pragma ENDDUMP
//----------------------------------------------------------------------------//
//5th July 2008. Testing User Defined DLL entry points into FWH
// This Module tests the *.Exe generated by FWH that will use the DLL
//----------------------------------------------------------------------------//
#include "FiveWin.ch"
function Main()
local cString := "Hello world from AC!"
local cString_2 := "Hello world from AC ... String 2!"
local nVal_3 := 4 //Integer value
DOPROC( "ONEPARAM", cString )
MsgInfo( "ok from EXE for One Parameter (one String)" )
DOPROC_2( "TWOPARAM", cString, cString_2 )
MsgInfo( "ok from EXE for Two Parameters (Two Strings)" )
DOPROC_3( "THREEPARAM", cString, cString_2, nVal_3 )
MsgInfo( "ok from EXE for Two Parameters (Two Strings) and a Numeric value" )
return nil
DLL FUNCTION DOPROC( cProc AS LPSTR, cText AS LPSTR ) AS LONG PASCAL LIB "MYDLL.dll"
DLL FUNCTION DOPROC_2( cProc AS LPSTR, cText AS LPSTR, cText_2 AS LPSTR ) AS LONG PASCAL LIB "MYDLL.dll"
DLL FUNCTION DOPROC_3( cProc AS LPSTR, cText AS LPSTR, cText_2 AS LPSTR, nVal AS WORD ) AS LONG PASCAL LIB "MYDLL.dll"
//----------------------------------------------------------------------------//
//5th July 2008. Testing C Code exe to call DLL written in FWH
#include <windows.h>
typedef long pascal ( * DOPROC ) ( char * cProcName, char * cString );
typedef long pascal ( * DOPROC_2 ) ( char * cProcName, char * cString, char * cString_2 );
typedef long pascal ( * DOPROC_3 ) ( char * cProcName, char * cString, char * cString_2, int nx );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
int nx;
HINSTANCE hDLL = LoadLibrary( "MyDLL.DLL" );
DOPROC pDoProc = ( DOPROC ) GetProcAddress( hDLL, "DOPROC" );
DOPROC_2 pDoProc_2 = ( DOPROC_2 ) GetProcAddress( hDLL, "DOPROC_2" );
DOPROC_3 pDoProc_3 = ( DOPROC_3 ) GetProcAddress( hDLL, "DOPROC_3" );
pDoProc( "ONEPARAM", "Hello world!" );
MessageBox( 0, "back in C EXE from Passing One String Parameter to DLL", "ok", 0 );
pDoProc_2( "TWOPARAM", "Hello world .. No 1!", "Hello world .. No 2!" );
MessageBox( 0, "back in C EXE from Passing Two String Parameter to DLL", "ok", 0 );
nx = 5;
pDoProc_3( "THREEPARAM", "Hello world .. No 1!", "Hello world .. No 2!", nx );
MessageBox( 0, "back in C EXE from Passing Two String Parameter and a Numeric to DLL", "ok", 0 );
FreeLibrary( hDLL );
return 0;
}
//----------------------------------------------------------------------------//
__declspec( dllexport ) LONG pascal DOPROC( char * cProcName, char * cParam )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!!
if( cProcName )
{
---> hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
hb_itemRelease( pItem );
}
else
MessageBox( 0, "inside the DLL ... One Parameter", "DOPROC", 0 );
---> return 0; }
__declspec( dllexport ) LONG pascal DOPROC( char * cProcName, char * cParam )
{
PHB_ITEM pItem = hb_itemPutC( NULL, cParam ); // Harbour builds the item !!!
if( cProcName )
{
hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
hb_itemRelease( pItem );
return hb_parnl( -1 ); // virtual machine returned numeric value !
}
else
MessageBox( 0, "inside the DLL ... One Parameter", "DOPROC", 0 );
return 123; // here you simply return the value 123
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 81 guests