LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing and reading a structure to dll function from LabWindows

How do I pass and read a structure to/from a VC++ DLL function from LabWindows/CVI 5.5.1?.

Ex:
__declspec(dllexport) int __stdcall PassToDLL(struct MyStruct TempStruct);


Also when I pass a structure data to DLL, LabWindows will freeze.

Ex: status = PassToDLL(MyStruct.data); where data is an integer.


Thanks,

Thu
0 Kudos
Message 1 of 4
(3,376 Views)
i've attached a small example of a dll made from VC that is used from CVI. It recives a structures and returns a value from it. The CVI project is under the debug folder. CVI will just print out the value that it retrieves form the structure. Im not sure what kind of structure you are using, or what parameters you are passing to the dll, but I hope this gives you a place to start.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 4
(3,376 Views)
Hi Bilal,

I followed your example and got this error message when building the DLL. Any idea why MS VC++ issue this error msg?.

" c:\mgcp.cpp(1382) : error C2491: 'UpdateGWdb' : definition of dllimport function not allowed
Error executing cl.exe. "


BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

STRUCTURE_API int UpdateGWdb(struct IPoA_Signaling IPoASigStruct)
{
//== =====

return test;
}
0 Kudos
Message 3 of 4
(3,376 Views)
It looks like you defined a function that expects a structure, but you're passing an integer (one element of the structure), not a structure.

PassToDLL(struct MyStryct TempStruct); // expects a structure

status = PassToDLL(MyStruct.data); // passes an integer

Try this:
status = PassToDLL(MyStruct); // passes a structure
0 Kudos
Message 4 of 4
(3,376 Views)