FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to declare this dll's parameter
Posts: 22
Joined: Mon May 19, 2008 08:54 PM
How to declare this dll's parameter
Posted: Mon Aug 18, 2008 06:39 PM

Hi guys,

I gotta work with a DLL that need to declare one parameter as structure.

I got a example in delphi and it show this parameter like this

    NBioAPI_FIR_PAYLOAD = record
            Length : DWORD;
            Data   : array of BYTE;
    end;

After call the dll im suppose to get the info parameter like this:

payload.length

or

payload.data

Thanks of any help

regards,
Diego Imenes

regards,



Diego Imenes
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Re: How to declare this dll's parameter
Posted: Mon Aug 18, 2008 07:53 PM
dempty wrote:Hi guys,

I gotta work with a DLL that need to declare one parameter as structure.

I got a example in delphi and it show this parameter like this

NBioAPI_FIR_PAYLOAD = record
Length : DWORD;
Data : array of BYTE;
end;

After call the dll im suppose to get the info parameter like this:

payload.length

or

payload.data



Thanks of any help

regards,
Diego Imenes


Diego, you can create a lib of this dll with the implib command of BCC55 like this and incorporate into you linkeditor list:

implib.exe dll_file.lib dll_file.dll
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 22
Joined: Mon May 19, 2008 08:54 PM
Re: How to declare this dll's parameter
Posted: Mon Aug 18, 2008 08:22 PM
JC wrote:
dempty wrote:Hi guys,

I gotta work with a DLL that need to declare one parameter as structure.

I got a example in delphi and it show this parameter like this

NBioAPI_FIR_PAYLOAD = record
Length : DWORD;
Data : array of BYTE;
end;

After call the dll im suppose to get the info parameter like this:

payload.length

or

payload.data



Thanks of any help

regards,
Diego Imenes


Diego, you can create a lib of this dll with the implib command of BCC55 like this and incorporate into you linkeditor list:

implib.exe dll_file.lib dll_file.dll


How could this help me? As I said the problem isnt work with DLL the problem is work with a dll that one of the parameters need to be a structure and not just a simple var

do you know structure? here is example how to declare a simple structure in c++

struct person
{
string name;
int age;
};
regards,



Diego Imenes
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to declare this dll's parameter
Posted: Tue Aug 19, 2008 03:24 AM

Diego,
I've never used structure so I can't answer your question directly however, the following might be of help to you:

  1. http://www.xharbour.com/xhdn/referenceg ... e&id=19643

  2. http://www.xharbour.com/xhdn/referenceg ... e&id=19640

But you'd need to register and login first.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to declare this dll's parameter
Posted: Tue Aug 19, 2008 06:12 AM
Diego,

You can create and manage a structure from FWH this way:
STRUCT oMyStruct
   MEMBER length AS LONG  // 32 bits
   MEMBER data AS LPSTR // pointer to a string stored outside the struct
ENDSTRUCT

or
STRUCT oMyStruct
   MEMBER length AS LONG  // 32 bits
   MEMBER data AS STRING LEN 100 // 100 bytes inside the struct
ENDSTRUCT

Please make a search for MEMBER in all FWH PRGs (sources and examples) and you will find a lot of examples.

Anyhow, sometimes is better to directly code it using C language. If you provide an example of use in Delphi, we will help you to convert it to C, that you can use from FWH + [x]Harbour
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 22
Joined: Mon May 19, 2008 08:54 PM
How to declare this dll's parameter
Posted: Tue Aug 19, 2008 11:27 AM

Thanks Antonio!

Now I'm in doubt with another stuff. How do I declare this parameter in dll code?

Here is the example in Delphi:

DLL declaration

NBioAPI_GetInitInfo = Function(hHandle : DWORD; nStructureType : BYTE ; pInitInfo : NBioAPI_INIT_INFO_PTR_0):DWORD; stdcall;

structure declaration

    NBioAPI_INIT_INFO_PTR_0 = ^NBioAPI_INIT_INFO_0;
    NBioAPI_INIT_INFO_0 = record
            StructureType        : DWORD;           // must be 0
            MaxFingersForEnroll  : DWORD;           // Default = 10
            SamplesPerFinger     : DWORD;           // Default = 2 : not used
            DefaultTimeout       : DWORD;           // Default = 10000ms = 10sec
            EnrollImageQuality   : DWORD;           // Default = 50
            VerifyImageQuality   : DWORD;           // Default = 30
            IdentifyImageQuality : DWORD;           // Default = 50
            SecurityLevel        : DWORD;           // Default = NBioAPI_FIR_SECURITY_LEVEL_NORMAL
    end;

As you can see my problem is just with the last parameter, that is: pInitInfo : NBioAPI_INIT_INFO_PTR_0

I declared this dll function like this in FWH

DLL32 FUNCTION NBioAPI_GetInitInfo(hHandle as DWORD, nStructureType as BYTE, pInitInfo as ??????) AS DWORD PASCAL LIB "NBioBSP.dll"

how about the last one with "??????" ? I really dont know how to declare the structure type info as a dll parameter.

Although, I''ve more than three functions in this dll with this kind of parameter

Thanks again for anyhelp!

regards,



Diego Imenes
Posts: 22
Joined: Mon May 19, 2008 08:54 PM
How to declare this dll's parameter
Posted: Tue Aug 19, 2008 12:22 PM

its solved!

i declared the structure in fwh in this away:

struct info
MEMBER StructureType AS DWORD
MEMBER MaxFingersForEnroll AS DWORD
MEMBER SamplesPerFinger AS DWORD
MEMBER DefaultTimeout AS DWORD
MEMBER EnrollImageQuality AS DWORD
MEMBER VerifyImageQuality AS DWORD
MEMBER IdentifyImageQuality AS DWORD
MEMBER SecurityLevel AS DWORD
endstruct

also i declared the dll

DLL32 FUNCTION NBioAPI_GetInitInfo(hHandle as DWORD, nStructureType as INT, pInitInfo as LPSTR) AS 12 PASCAL LIB "NBioBSP.dll"

calling the function

NBioAPI_GetInitInfo(teste, 0, @info:cbuffer)

and after i could get all information that i need

? info:StructureType,info:MaxFingersForEnroll,info:SamplesPerFinger,info:DefaultTimeout,info:EnrollImageQuality,info:VerifyImageQuality,info:IdentifyImageQuality,info:SecurityLevel

it works fine! thanks antonio

regards,



Diego Imenes
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to declare this dll's parameter
Posted: Tue Aug 19, 2008 04:27 PM

Diego,

Excellent! :-)

Yes, LPSTR is the way to provide the pointer to the structure contents

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion