LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem configuring dll in call library function node

Hi all,

I need help on configuring an external dll into labview. I used import shared library wizard with dll’s header file and got almost all functions (tested, works OK.) except ones with pointer arguments. And I am trying to configure the rest myself. dll belongs to a laser unit to configure, read and save data etc. Definition for one of the functions in the dll is below.

 

GetCurState(HANDLE hDev, SLOTSELECT SlotSelector, pPOS pposLaser,pPOS pposLsrRes,pPOS pposEncoder,PFLOAT pulBeamStren,PULONG
pulSamples,PTRIGSTAT pTrigstat); 

 

And from documentation

 

typedef union {

    DOUBLE dPosition;

    LONGLONG llPosition;

    LONG lRawPos;

    } POS, *pPOS;

 

typedef WORD TRIGSTAT, *PTRIGSTAT;

 

typedef FLOAT *PFLOAT;

 

typedef ULONG *PULONG;

 

I acquire device handle hDev from other function in the dll (and also used them with function with no pointer arguments).

I tried Adapt to Type or Numeric 8-byte double for function parameters and tried wiring numeric, numeric array  control and indicator for above parameters in trhe union with no success. Function returns no error but sometimes labview crash.

 

I read about using union in labview and it was saying to use largest element in size in a union, so I guess the question is what do I wire to a pointer type argument/parameter.  For example do I connect a numeric control and indicator to both a pass by Value and pass by Pointer to Value?

 

Thanks,

 

 

0 Kudos
Message 1 of 4
(2,397 Views)

Yes, for a union you'd use a datatype that corresponds to the largest element in the union. In you case you had a DOUBLE (64-bits), LONGLONG (64-bits), and LONG (32-bits). Thus, you'd use a 64-bit value, such as  DBL control. For the pointer you'd need to use the size of the pointer that the compiler was using. If your DLL is a 32-bit DLL then you'd use a 32-bit integer. If your DLL is a 64-bit DLL then you'd use a 64-bit integer. Note that just because your union has a LONGLONG, it does not necessarily mean you have a 64-bit DLL. For instance, LabVIEW has 64-bit integers, even in the 32-bit version.

Message 2 of 4
(2,394 Views)

Thanks for the answer. I think it cleared some of the question in my head. Also how do I know if a dll is 32 or 64 bit? I haven't seen that info in dll's document.

0 Kudos
Message 3 of 4
(2,362 Views)

Dependency Walker can tell you that. For 64-bit modules it will show a little "64" next to the icon in the tree.

0 Kudos
Message 4 of 4
(2,351 Views)