How to declare this dll's parameter

Post Reply
dempty
Posts: 22
Joined: Mon May 19, 2008 8:54 pm

How to declare this dll's parameter

Post by dempty »

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
User avatar
JC
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil
Contact:

Re: How to declare this dll's parameter

Post by JC »

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
dempty
Posts: 22
Joined: Mon May 19, 2008 8:54 pm

Re: How to declare this dll's parameter

Post by dempty »

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;
};
hua
Posts: 1075
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Post by hua »

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.
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Diego,

You can create and manage a structure from FWH this way:

Code: Select all | Expand

STRUCT oMyStruct
   MEMBER length AS LONG  // 32 bits
   MEMBER data AS LPSTR // pointer to a string stored outside the struct
ENDSTRUCT

or

Code: Select all | Expand

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
Last edited by Antonio Linares on Tue Aug 19, 2008 4:24 pm, edited 1 time in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
dempty
Posts: 22
Joined: Mon May 19, 2008 8:54 pm

Post by dempty »

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!
dempty
Posts: 22
Joined: Mon May 19, 2008 8:54 pm

Post by dempty »

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
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Diego,

Excellent! :-)

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

Antonio Linares
www.fivetechsoft.com
Post Reply