Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #9432

Re: How to integrate C DLL into VO and generate interface code

From "Gerhard Bunzel" <g.bunzel@domonet.de>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: How to integrate C DLL into VO and generate interface code
Date 2016-06-15 14:34 +0200
Organization (posted via) M-net Telekommunikations GmbH
Message-ID <njri0l$ef7$1@news.m-online.net> (permalink)
References <66abaae4-be73-486e-a8d8-b44d0592b744@googlegroups.com> <7de24866-5bfe-439f-befb-099a84afe0d0@googlegroups.com> <dr7s82Fkp19U1@mid.individual.net> <b21ed327-184e-482f-96ea-73b551cb6963@googlegroups.com>

Show all headers | View raw


Alexander,

>....besides “17” is the recommended value from the DLL provider.

Then you maybe have to use 'ALIGN 1' to declare that data structure.

From VO-Help:
Explicit (manual ) Structure Alignment

In some situations you need to match a structure declaration from a C/C++ 
header file that has explicit alignment. Then you need to add the ALIGN 
clause to your structure declaration.
This forces the compiler to align the structure elements to a multiple of 
the specified size.
An alignment of 1 tells the compiler NOT to use padding but to align all 
elements of a structure next to eachother. This is the most compact, but may 
be slower.

Search for 'ALIGN' in the VO helpfile


Do you have a C-Sample to use that DLL?


HTH

Gerhard Bunzel


schrieb im Newsbeitrag 
news:b21ed327-184e-482f-96ea-73b551cb6963@googlegroups.com...

Ok, now the reader finally arrived. After issues with the driver I am now 
able to test :-)

Basic functions like OpenReader() and GetNumberOfItems()  (i.e. the 
RFID-tags on it) are working after I identified the correct DLL entry points 
using Dependency Walker. Thanks for your help!

However, the application crashes when I try to read information from an RFID 
tag via GetItem() that uses the structure.

The (shortened) declaration now is:
------
structure TRPINFO
MEMBER isUserCard as logic
MEMBER numberOfParts as int
MEMBER uID as ptr
[...further PTRs]

_dll FUNCTION GetItem(nTrpNr as int, oTrpInfo as TRPINFO) as int 
PASCAL:RFIDDLL.?GetItem@@YAHHPAUTRPINFO@@@Z
------

From VO I call:

-----
local ptrStruct is TRPINFO

ptrStruct.isUserCard:=false
ptrStruct.numberOfParts:=0
ptrStruct.uID:=MemAlloc(17)


Qout(“before”)
nRet:=GetItem(nItem, @ptrStruct)
Qout(“after”)
------

The application crashes hardly when GetItem is called without the VO error 
handler popping up. Qout(“after”) is never reached.

Log files of the supplier from within the DLL’s GetItem function indicate 
that this happens when the function tries to populate my string “uID”, 
probably due to memory issues.

Some thoughts:

- I am not quite clear whether to use “AS” or “IS” when defining ptrStruct. 
VO-help says that “IS” is taking care of memory allocation whereas “AS” 
doesn’t. Exchanging AS/IS doesn’t help.

- Increasing the size of MemAlloc(17) to e.g. MemAlloc(500) does not help, 
besides “17” is the recommended value from the DLL provider. Maybe I have to 
add another byte for null-terminated string?

- Allocating entire space for ptrStruct using 
ptrStruct=MemAlloc(_sizeof(ptrStruct)) does not help either.

- Call-by-reference (@) seems to be required I guess.


Any clue or best practice to allocate and forward structures containing 
strings to a DLL function?

Best,
Alex 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to integrate C DLL into VO and generate interface code Alexander Schmitt <alexander.schmitt@paidosoft.de> - 2016-05-31 03:52 -0700
  Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-05-31 16:11 +0200
  Re: How to integrate C DLL into VO and generate interface code "Karl-Heinz" <invalid@invalid.invalid> - 2016-05-31 16:07 +0200
  Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-01 02:13 -0700
    Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-01 12:36 +0200
    Re: How to integrate C DLL into VO and generate interface code "Karl-Heinz" <invalid@invalid.invalid> - 2016-06-01 12:37 +0200
      Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-14 14:05 -0700
        Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-15 08:59 +0200
        Re: How to integrate C DLL into VO and generate interface code "Karl-Heinz" <invalid@invalid.invalid> - 2016-06-15 09:40 +0200
        Re: How to integrate C DLL into VO and generate interface code "Gerhard Bunzel" <g.bunzel@domonet.de> - 2016-06-15 14:34 +0200
          Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-15 14:06 -0700
            Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-16 05:56 +0200
            Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-16 06:03 +0200
              Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-16 14:28 -0700
                Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-19 13:23 -0700
                Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-20 07:29 +0200
            Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-21 06:21 +0200
              Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-06-22 12:37 -0700
                Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-23 04:05 +0200
                Re: How to integrate C DLL into VO and generate interface code alexander.schmitt@paidosoft.de - 2016-07-03 13:53 -0700
                Re: How to integrate C DLL into VO and generate interface code "Karl-Heinz" <invalid@invalid.invalid> - 2016-07-05 21:19 +0200
  Re: How to integrate C DLL into VO and generate interface code "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-20 09:16 +0200
    Re: How to integrate C DLL into VO and generate interface code "Karl-Heinz" <invalid@invalid.invalid> - 2016-06-20 12:35 +0200

csiph-web