LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Create an Import Library for a DLL

CVI is generally very compatible with windows.h and the windows sdk (as long as windows.h is included first), so I have never tried changing a header to avoid the windows.h dependancies.   But I don't know of any reason why changes to the header would not work.

0 Kudos
Message 11 of 15
(1,488 Views)
As long as it works with windows.h I'll not change anything 😉

But I just ran into another problem. I did some reading on the integration of dll functions (How Can I Access DLL Functions in a LabWindows/CVI Program without Including the Import Library in t...) and tried to access my LibOpto functions the described way. After some trial and error I just got one last compile error stating Missing prototype for the CloseDriver function. OpenDriver and DAQ_Info worked fine but they both take parameters.
Since CloseDriver doesn't take parameters I suspect it has to do something with that... but I've got NO idea what exactly could cause the problem.

LibOpto.h:
...
__declspec(dllexport) int OptoPCI_OpenDriver ( char szShortPath[260] );
__declspec(dllexport) int OptoPCI_CloseDriver ( );
__declspec(dllexport) int OptoPCI_DAQ_Info ( VXD_VERSION_INFO *VersionInfo );
...
typedef int (*OPTO_OPENDRIVER)(char szShortPath[260]);
typedef int (*OPTO_CLOSEDRIVER)();
typedef int (*OPTO_DAQ_INFO)(VXD_VERSION_INFO *VersionInfo);
...


LibOpto_dll_test.c:
...
OPTO_OPENDRIVER OpenDriver = (OPTO_OPENDRIVER) GetProcAddress ( hinstLib, "OptoPCI_OpenDriver" );
OPTO_CLOSEDRIVER CloseDriver = (OPTO_CLOSEDRIVER) GetProcAddress ( hinstLib, "OptoPCI_CloseDriver" );
OPTO_DAQ_INFO DAQ_Info = (OPTO_DAQ_INFO) GetProcAddress ( hinstLib, "OptoPCI_DAQ_Info" );
...
iRet = OpenDriver("");   //No Error here
iRet = DAQ_Info(&VersionInfo);   //No Error here
iRet = CloseDriver ( );   //Error: Missing prototype
...

Any ideas?

0 Kudos
Message 12 of 15
(1,484 Views)
Try replacing:
 
__declspec(dllexport) int OptoPCI_CloseDriver ( );
and
typedef int (*OPTO_CLOSEDRIVER)();
 
with
 
__declspec(dllexport) int OptoPCI_CloseDriver (void);
and
typedef int (*OPTO_CLOSEDRIVER)(void);
Just a guess, but most C compilers require the 'void' when you declare a function that takes no parameters.
 
Hope that's it!
 
-alex

Message Edited by Alex D on 05-01-2006 10:28 AM

Message Edited by Alex D on 05-01-2006 10:29 AM

Message 13 of 15
(1,485 Views)
I think Alex is right.  No parameters would be  a void in C. 
Message 14 of 15
(1,464 Views)
omg... did the "trick"!

Think I'll have to learn quit a lot 😉

Now it works so far as that I'm able to access the driver. And there I've got another question, I had do use an external tool to load/unload the .sys driver for the interface card, is there a way to do this directly from within CVI?
Actually I would like to write a CVI Instrument Driver to access all the functions in a more convenient way and better re-usability... Will be quite a challange but a good training after the CVI Basics I Course 🙂


0 Kudos
Message 15 of 15
(1,447 Views)