LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with a struct that i need to pass to a dll

I have just received an SDK from a third party vendor.
I need to pass a struct to a dll in order to use our measuring arm.
 
Here's the definition of the struct
 
struct vOpenInfo
{
        int                 nFuncType;       // = DLL_OPEN_CMM (or 1)
        HWND         hwnd;
        WCHAR      sSaveDir[128];
        void             (*HelpCallBack)();
};
 
Here's the definition of the only function that I can access from the DLL
 
int CmmSpecific(void *)
 
From what I understand the CmmSpecific function use the pointer on the structure to know what I want to do.
 
The only problem, is that I need to transform LabVIEW data onto that type of struct.
 
Does anybody have an idea how can I do it?
 
Thanks in advance
 
 
 
 
0 Kudos
Message 1 of 3
(2,567 Views)
Hi Julien,

I think you'd benefit greatly from browsing through the Using External Code in LabVIEW product reference. Windows also maintains data types in its API reference that will help you search through the product reference manual.

Still, a cluster in LabVIEW is the equivalent of a struct in text-based languages. Here is some information for populating that cluster:

HWND --
I'm trying to access Window Handle (HWND) in Labview discussion forum post
WCHAR -- Can I call a function from a dll in LabVIEW that returns:double*string and int. discussion forum post

Cheers.
Michael K.

| Michael K | Project Manager | LabVIEW R&D | National Instruments |

0 Kudos
Message 2 of 3
(2,551 Views)


@Julien Tozzi wrote:
I have just received an SDK from a third party vendor.
I need to pass a struct to a dll in order to use our measuring arm.
 
Here's the definition of the struct
 
struct vOpenInfo
{
        int                 nFuncType;       // = DLL_OPEN_CMM (or 1)
        HWND         hwnd;
        WCHAR      sSaveDir[128];
        void             (*HelpCallBack)();
};
 
Here's the definition of the only function that I can access from the DLL
 
int CmmSpecific(void *)
 
From what I understand the CmmSpecific function use the pointer on the structure to know what I want to do.
 
The only problem, is that I need to transform LabVIEW data onto that type of struct.
 
Does anybody have an idea how can I do it?

The previous post is basically correct but one thing catches my eye here and that is the fourth element in the structure which is a function pointer. The LabVIEW system can't really deal with this without quite some involved programming I would not recommend anyone to try without some very good C programming knowledge.

So if the API description doesn't tell you that it is valid to just pass in here a NULL value to disable the callback, writing a wrapper DLL that translates this into a more LabVIEW friendly interface is by far easier to do.

Rolf Kalbermatter

Message Edited by rolfk on 01-11-2007 10:09 AM

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 3
(2,543 Views)