create a harbour dll containing functions to be executed

Re: create a harbour dll containing functions to be executed

Postby Antonio Linares » Wed Sep 07, 2016 2:08 pm

Romeo,

Please include the code that I posted here inside #pragma BEGINDUMP ... ENDDUMP

viewtopic.php?p=193644#p193644
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: create a harbour dll containing functions to be executed

Postby Perry Nichols » Thu Sep 08, 2016 6:53 pm

Antonio,

Do you know if you can call a harbour DLL from a C# .Net exe ? If so can you provide an example?
Perry Nichols
 
Posts: 17
Joined: Thu Feb 28, 2008 6:56 pm

Re: create a harbour dll containing functions to be executed

Postby Antonio Linares » Thu Sep 08, 2016 8:28 pm

Perry,

Here you have an example that I coded for FiveNet:

https://bitbucket.org/fivetech/fivenet/src/fdc55d7abee75799ae25b716c4c79c06556aa8ee/source/cs/fivetech.cs?at=master&fileviewer=file-view-default

Look for:

public class FiveNet
{
// public string AppName;

[ DllImport ( "ftsnet.dll", CallingConvention = CallingConvention.Cdecl ) ]
public static extern void One( uint pBlock );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: create a harbour dll containing functions to be executed

Postby rkurian » Thu Sep 08, 2016 8:51 pm

Antonio,

I'm not sure that I have the Harbour DLL setup properly. I receive the following error

An unhandled exception of type 'System.EntryPointNotFoundException' occurred in WindowsFormsApplication1.exe

Additional information: Unable to find an entry point named 'OneParam' in DLL 'Mydll.dll'.


This is the code we are using for the DLL

// Build a DLL from this code using: buildhd.bat mydll
// Please review TESTMYDL.prg to see how to use this DLL.

//----------------------------------------------------------------------------//

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 );

if( cProcName )
{
hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
hb_itemRelease( pItem );
}
else
MessageBox( 0, "inside the DLL", "DOPROC", 0 );

return 0;
}

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;
}
#pragma ENDDUMP

//----------------------------------------------------------------------------//
rkurian
 
Posts: 1
Joined: Wed Aug 31, 2016 3:26 pm

Re: create a harbour dll containing functions to be executed

Postby Antonio Linares » Thu Sep 08, 2016 10:07 pm

You are not exporting OneParam() from the DLL so you can not call OneParam() directly from your EXE.

You have to call DOPROC() from your EXE, as it is the exported function of the DLL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: create a harbour dll containing functions to be executed

Postby Romeo » Mon Sep 19, 2016 9:07 am

NO more help ?
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: create a harbour dll containing functions to be executed

Postby Romeo » Mon Sep 19, 2016 9:36 am

Hi dear Perry Nichols,
please can you kindly send me at romeox@tiscali.it those files:

MYDLL.PRG
TESTMYDLL.PRG
BUILDHD.BAT

I wrong samethins in my files, and it doesnot work !

FWH 16.02
many thanks
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: create a harbour dll containing functions to be executed

Postby Romeo » Mon Sep 19, 2016 9:53 am

OK, i retrive my error.

it works now !

tks
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: create a harbour dll containing functions to be executed

Postby Antonio Linares » Mon Sep 19, 2016 11:21 am

very good :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 98 guests