OT: .DLL interface
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Re: OT: .DLL interface
Tim;
Hi. Never mind the size of the resulting .lib. It does not contain any code. It's just declarations for the linker. The actual code stays on the .dll. I also think that you should be able to have this working with xhb (xcc), so you shouldn't add the overhead of moving your dev environment over to bcc.
Although I consider that writing a c wrapper function as a very simple task, what you need seems to be a bit more complicated as you are not only calling a .dll function but also providing a pointer for one of those functions to call bck another c func that calls another a .prg function (I know I get lost here...).
Please send me your email address (reinaldo dot crespo at gmail) so that I can share with you some text about how c wrapper functions works with xharbour. That might not totally solve your problem, but it will help you get started or at least understand a little of what Antonio is doing. Thank God Antonio is helping.
Reinaldo.
Hi. Never mind the size of the resulting .lib. It does not contain any code. It's just declarations for the linker. The actual code stays on the .dll. I also think that you should be able to have this working with xhb (xcc), so you shouldn't add the overhead of moving your dev environment over to bcc.
Although I consider that writing a c wrapper function as a very simple task, what you need seems to be a bit more complicated as you are not only calling a .dll function but also providing a pointer for one of those functions to call bck another c func that calls another a .prg function (I know I get lost here...).
Please send me your email address (reinaldo dot crespo at gmail) so that I can share with you some text about how c wrapper functions works with xharbour. That might not totally solve your problem, but it will help you get started or at least understand a little of what Antonio is doing. Thank God Antonio is helping.
Reinaldo.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
I have inspected your EXE and it seems it is not exporting the required C function, thats probably why the application hangs.
As I have commented you by email, it seems as PellesC is not properly managing the __declspec(dllexport) directive.
At this point my advise is to try it using Borland or Microsoft.
I have inspected your EXE and it seems it is not exporting the required C function, thats probably why the application hangs.
As I have commented you by email, it seems as PellesC is not properly managing the __declspec(dllexport) directive.
At this point my advise is to try it using Borland or Microsoft.
Re: OT: .DLL interface
I tried with Borland but it found an error
I had to create a new .lib file ( IMPLIB ) so it would be Borland compatible. The bottom line is that the linker does not see the functions from that .lib so I can't get a build.
I had to create a new .lib file ( IMPLIB ) so it would be Borland compatible. The bottom line is that the linker does not see the functions from that .lib so I can't get a build.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
You have to create the import library for Borland this way:
implib.exe wcap.lib wcap.dll
You have to create the import library for Borland this way:
implib.exe wcap.lib wcap.dll
Re: OT: .DLL interface
I did that ... followed your directions from one of the original posts ...
I then put the library in the linker path with all the other .lib files
The build yields this message:
--------------------Configuration: wcap - Debug--------------------
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_WCAPRegisterReceive' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPConnectAS' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPConnected' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPDisconnect' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPSend' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
wcap.EXE - 5 error(s), 0 warning(s)
I then put the library in the linker path with all the other .lib files
The build yields this message:
--------------------Configuration: wcap - Debug--------------------
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_WCAPRegisterReceive' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPConnectAS' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPConnected' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPDisconnect' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
Error: Unresolved external '_WCAPSend' referenced from C:\USERS\TIM STONE\DOCUMENTS\PROJECTS\ASW9\DEBUG\WPAC.OBJ
wcap.EXE - 5 error(s), 0 warning(s)
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
Have you included wcap.lib in the UEStudio FWH settings ?
Have you included wcap.lib in the UEStudio FWH settings ?
Re: OT: .DLL interface
It is in the application file for xHarbour in the FWH libraries listing, with reference to the proper directory.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
I see whats going on, the functions are in pascal mode.
So in your code you have to make these changes to use the right prototypes:
void pascal WCAPRegisterReceive( LONG);
BOOL pascal WCAPConnectAs( LPSTR, LONG, LONG );
BOOL pascal WCAPConnected( void );
void pascal WCAPDisconnect( void );
void pascal WCAPSend( LPSTR );
I see whats going on, the functions are in pascal mode.
So in your code you have to make these changes to use the right prototypes:
void pascal WCAPRegisterReceive( LONG);
BOOL pascal WCAPConnectAs( LPSTR, LONG, LONG );
BOOL pascal WCAPConnected( void );
void pascal WCAPDisconnect( void );
void pascal WCAPSend( LPSTR );
Re: OT: .DLL interface
VICTORY ! I got a build and it did connect.
Only 1 question left ... with the modified CalledBack( ) system, how can I read the reply message ? In other words, their .dll uses CalledBack( ) to place an XML response ...
Only 1 question left ... with the modified CalledBack( ) system, how can I read the reply message ? In other words, their .dll uses CalledBack( ) to place an XML response ...
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
Very good!
Now, lets jump from C level to PRG code...
I am writing the code
Very good!
Now, lets jump from C level to PRG code...
I am writing the code
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
You have to modify this function this way:
And add this function in your PRG code:
Code: Select all
#include <hbvm.h>
void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize )
{
hb_vmPushSymbol( hb_dynsymGetSymbol( "CALLBACK" ) ); // we push the symbol of the function to call
hb_vmPushNil(); // we push nil for a function, a codeblock for Eval, an object for a method
hb_vmPushString( szXML, strlen( szXML ) );
hb_vmPushLong( lSize );
hb_vmFunction( 2 ); // two parameters supplied to CallBack()
}
Code: Select all
function CallBack( cXML, nSize )
MsgInfo( cXML, "It works!" )
return nil
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
Do you have an example for their CalledBack() pascal code ?
Do you have an example for their CalledBack() pascal code ?
Re: OT: .DLL interface
Here is their Delphi code:
Here is their VB code:
Code: Select all
procedure CalledBack(PC: PChar);
var
sDocType, sText :String;
iX :Integer;
XmlList :TXmlNodeList;
begin
with Form1 do
begin
Memo1.Text := Form1.Memo1.Text + String(PC);
Inc(Form1.FCount);
lblDLLStatus.Caption := IntToStr(Form1.FCount);
iX := Pos('Hello', String(PC));
if (iX > 40) AND (iX < 60) then
begin
xmlObject.ClearDocument;
xmlObject.LoadMemory(PC);
sDocType := Trim(xmlObject.Document.DocumentElement.TagName);
if sDocType = 'Hello' then
begin
XmlList :=
xmlObject.Document.DocumentElement.SelectNodes('Win32WindowHandle');
if XmlList.Length > 0 then //need to tranlate AAIA code
begin
sText := TXmlElement(XmlList.Item(0)).ElementText;
try
FServerHandle := StrToInt(sText);
lblSetFocus.Font.Color := clBlue;
except
FServerHandle := 0;
end;
XmlList.Free;
end;
end;
end;
end;
end; {CalledBack}
Code: Select all
Sub CalledBack(ByVal lpszXMLDoc As Long)
Dim sXMLDoc As String
Dim iLen As Integer
iLen = lstrlen(lpszXMLDoc)
sXMLDoc = String$(iLen, 0)
Call lstrcpy(sXMLDoc, lpszXMLDoc)
Form1.Text1.Text = sXMLDoc
End Sub
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: OT: .DLL interface
Tim,
It seems as they don't return anything to the DLL...
It seems as they don't return anything to the DLL...
-
- Posts: 77
- Joined: Sun Aug 26, 2007 11:53 pm
Re: OT: .DLL interface
Hi Tim
For a matter of interest what is this DLL used for?
I am dabbling in writing c (Borland) code for inclusion in my Harbour progs.
So far I've only modified existing c functions included in FW od xHarbour.
In following your experience tn this toppic this interface has provided me with a few tips.
I wonder if anyone has further info I read up on (not only for DLL interfaces)?
Thanks!
For a matter of interest what is this DLL used for?
I am dabbling in writing c (Borland) code for inclusion in my Harbour progs.
So far I've only modified existing c functions included in FW od xHarbour.
In following your experience tn this toppic this interface has provided me with a few tips.
I wonder if anyone has further info I read up on (not only for DLL interfaces)?
Thanks!