Tim,
For Microsoft and PellesC, please replace _export with __declspec(dllexport) and try to build it again, thanks ![]()
Tim,
For Microsoft and PellesC, please replace _export with __declspec(dllexport) and try to build it again, thanks ![]()
#INCLUDE "Fivewin.CH"
#pragma BEGINDUMP
// Declare Sub WCAPRegisterReceive Lib "wcap.dll" _ (ByVal lpRcvProcedure As Long)
#include <windows.h>
void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize );
{
MessageBox( 0, "It is working", szXML, 0 );
}
HB_FUNC( REGISTER )
{
WCAPRegisterReceive( ( LONG ) RcvProcedure );
}
#pragma ENDDUMP
FUNCTION main // wpac
LOCAL pFunc := HB_FuncPtr( "CalledBack" )
//PRIVATE wcap := LoadLibrary( "wcap.dll" )
PRIVATE cXMLDoc := ""
// Register the procedure
Register( )
// Connect to the server
WCAPConnectAs( 'localhost', 17943, 1 )
WCAPConnected()
MsgInfo( "Got Here" )
WCAPDisconnect( )
FreeLibrary( wcap )
QUIT
RETURN NIL
FUNCTION CalledBack( PC )
cXMLDoc := PC
RETURN NILType: C >>>xhb.exe -o"WPAC\wPac.c" -m -n -pOWPAC\ -q -gc0 -I"C:\fwh\include" -I"C:\xHB\include" -I"C:\xHB\include\w32" "C:\xHB\ASW90\wPac.prg"<<<
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6726)
Copyright 1999-2010, http://www.xharbour.org <!-- m --><a class="postlink" href="http://www.harbour-project.org/">http://www.harbour-project.org/</a><!-- m -->
Generating object output to 'WPAC\wPac.obj'...
C:\\xHB\\ASW90\\wPac.prg(10): error: Unrecognized declaration.
C:\\xHB\\ASW90\\wPac.prg(11): warning: Missing type specifier.
C:\\xHB\\ASW90\\wPac.prg(11): error: Syntax error; found '0' expecting ')'.
C:\\xHB\\ASW90\\wPac.prg(11): error: Redeclaration of 'MessageBoxA' previously declared at C:\xHB\c_include\win\winuser.h(4283): found 'int __cdecl function' expected 'int __stdcall function(struct HWND__ *, const char *, const char *, unsigned int)'.
C:\\xHB\\ASW90\\wPac.prg(12): error: Unrecognized declaration.
C:\\xHB\\ASW90\\wPac.prg(16): warning: Missing prototype for 'WCAPRegisterReceive'.
Type: C >>>Couldn't build: wPac.obj<<<
Type: C >>>TMAKEOBJECT<<<
Type: C >>>TMAKEOBJECT:REFRESH<<<
Type: N >>> 1423<<<I assumed the other functions would work since they are in the lib, but they are not seen. Without using them I do get an .exe. However, I do not get the message box you included which says it is working.
void WCAPConnectAs( char *, LONG, LONG ); // I have assumed this prototype, please check that it is correct
HB_FUNC( WCAPCONNECTAS )
{
WCAPConnectAs( hb_parc( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) );
}#INCLUDE "Fivewin.CH"
#pragma BEGINDUMP
#include <windows.h>
void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize )
{
MessageBox( 0, "It is working", szXML, 0 );
}
// Declare Sub WCAPRegisterReceive Lib "wcap.dll" _ (ByVal lpRcvProcedure As Long)
void WCAPRegisterReceive( LONG);
HB_FUNC( REGISTER )
{
WCAPRegisterReceive( ( LONG ) RcvProcedure );
}
// Function: WCAPConnectAs( Host:LPSTR, Port :UINT, Autostart :UINT ) :Bool
void WCAPConnectAs( LPSTR, LONG, LONG );
HB_FUNC( WPCONNECTAS )
{
WCAPConnectAs( hb_parc(1), hb_parl(2), hb_parl(3) );
}
// Function: WCAPConnected :BOOl
void WCAPConnected( );
HB_FUNC( WPCONNECTED )
{
WCAPConnected( );
}
// Function: WCAPDisconnect
void WCAPDisconnect( );
HB_FUNC( WPDISCONNECT )
{
WCAPDisconnect( );
}
// Function: WCAPSend(XMLDoc :LPSTR)
void WCAPSend( LPSTR );
HB_FUNC( WPSEND )
{
WCAPSend( hb_parc(1) ) ;
}
#pragma ENDDUMP
FUNCTION main // wpac
LOCAL pFunc := HB_FuncPtr( "CalledBack" )
PRIVATE cXMLDoc := ""
// Register the procedure
Register( )
// Connect to the server
WConnectAs( 'localhost', 17943, 1 )
// WCAPConnected()
MsgInfo( "Got Here" )
// WCAPDisconnect( )
QUIT
RETURN NIL
FUNCTION CalledBack( PC )
cXMLDoc := PC
RETURN NIL#INCLUDE "Fivewin.CH"
#pragma BEGINDUMP
#include <windows.h>
void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize )
{
MessageBox( 0, "It is working", szXML, 0 );
}
// Declare Sub WCAPRegisterReceive Lib "wcap.dll" _ (ByVal lpRcvProcedure As Long)
void WCAPRegisterReceive( LONG );
HB_FUNC( REGISTER )
{
WCAPRegisterReceive( ( LONG ) RcvProcedure );
}
// Function: WCAPConnectAs( Host:LPSTR, Port :UINT, Autostart :UINT ) :Bool
BOOL WCAPConnectAs( LPSTR, LONG, LONG );
HB_FUNC( WPCONNECTAS )
{
hb_retl( WCAPConnectAs( ( char * ) hb_parc( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) );
}
// Function: WCAPConnected :BOOl
BOOL WCAPConnected( );
HB_FUNC( WPCONNECTED )
{
hb_retl( WCAPConnected() );
}
// Function: WCAPDisconnect
void WCAPDisconnect();
HB_FUNC( WPDISCONNECT )
{
WCAPDisconnect();
}
// Function: WCAPSend(XMLDoc :LPSTR)
void WCAPSend( LPSTR );
HB_FUNC( WPSEND )
{
WCAPSend( ( char * ) hb_parc( 1 ) );
}
#pragma ENDDUMP
FUNCTION main // wpac
LOCAL pFunc := HB_FuncPtr( "CalledBack" )
PRIVATE cXMLDoc := ""
// Register the procedure
Register( )
// Connect to the server
WConnectAs( 'localhost', 17943, 1 )
// WCAPConnected()
MsgInfo( "Got Here" )
// WCAPDisconnect( )
QUIT
RETURN NIL
FUNCTION CalledBack( PC )
cXMLDoc := PC
RETURN NILStill getting a fight from ConnectAs: The link returns an error Undefined __WCAPConnectAs
Also, did you mean to put BOOL WCAPConnectAS( LPSTR,LONG,LONG) instead of void ?
Tim,
This line has to be modified this way: (please notice uppercase ...AS)
hb_retl( WCAPConnectAS( ( char * ) hb_parc( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) );
Yes, based on the pascal prototype that you wrote, the function returns a logical value (BOOL).
It now compiles ! This is good progress. However, the program dies without any message at REGISTER( ).
HB_FUNC( REGISTER )
{
MessageBox( 0, "before", "register", 0 );
WCAPRegisterReceive( ( LONG ) RcvProcedure );
MessageBox( 0, "after", "register", 0 );
}Tim,
Also, please create a DEF file from the EXE:
impdef.exe test.def test.exe
and copy the DEF file here, thanks
Interesting,
Here is the Main():
FUNCTION main // wpac
MsgInfo("1")
// Register the procedure
Register( )
MsgInfo("2")
// Connect to the server
WPConnectAs( 'localhost', 17943, 1 )
MsgInfo("3")
WPConnected()
MsgInfo( "4" )
WPDisconnect( )
MsgInfo( "5" )
RETURN NIL
I get Msg 1, before, after, but no message 2 which comes right after the call to Register()
impdef is getting me a 0 byte file. Of course it is created with xBuilder / Pelles C ....
Tim,
Please send me a ZIP file (renamed as *.ZOP) with your EXE, thanks
Following all of the suggestions, and your very much appreciated guidance, Run of this application locks up the computer. Here are some observations:
1) The build with xBuilder used FWH 10.9 and xCC compiler.
2) The .dll I provided was 406KB. The lib you created was 4KB. Is that possible and still accurate
3) I did try a build with BCC in a UE project, but my lib was Microsoft C ... and I also got an error with a Borland .h file.
" Error E2187 c:\bcc582\include\prsht.h 1084: Unexpected end of file in conditional started on line 12 "
I suspect something else because I would expect that to be clean.
4) I tried to IMPLIB the .dll and it only yields a 2KB file. I like compression but that seems unlikely also.
Perhaps I just need to go back to using the .dll. I can do that easily in VB so maybe I need to call an intermediary vb routine that does this all for me ...