LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a DLL in Labwindows/CVI for Visual Basic

Hi !
 
 
I know how to create a DLL and to use them my Labwindows/CVI programs. But a colleague wants to use a DLL I made in Visual Basic 6.0 but we can't get it to work. When trying to use the DLL and making a reference to it in VB we get the error "Can't add a reference to the specified file"
 
All functions in the DLL have following look:
 
short int DLLEXPORT DLLSTDCALL i16_NI6602_ResetCounter( char *pc_ErrMsg, 
                                                                                                          short int i16_Device,
                                                                                                          unsigned short int u16_Counter );
 
I suppose this is very standard stuff and we forgot something silly. I only supplied the DLL. Does VB need something more ?
 
Thanks.
0 Kudos
Message 1 of 7
(4,306 Views)
Come on guys ! I need help on this !
0 Kudos
Message 2 of 7
(4,283 Views)

OK ! I found a button to generate a header file for visual basic. My colleague has put that in his code and he can continue developing his program. I hope to hear soon from him that the DLL works.

In the mean time I'm busy  making a .fp .Together with putting some lib-stuff in the DLL itself this could also fix the problems (so one of the help docs says...)

(If it works I'm going to give myself 5 stars 😉 )
0 Kudos
Message 3 of 7
(4,275 Views)

Hi Han

The reason you got that error was because VB required type libraries when it loads them as a reference. A type library is usually a tlb file that accompanies the DLL or is embedded in the DLL. If its a standalone tlb file, you would add that as a reference to VB instead of the DLL. CVI by default will not generate type libraries for its DLLs. You will need to associate it with a function panel to get type libraries.

The header option will work. The bas file generated provides VB with DLL information about the function and its parameters. Once you add this file to the VB project, you would be able to call into the DLL. It works best when the dll is in the system32 folder.

Bilal Durrani
NI
0 Kudos
Message 4 of 7
(4,269 Views)

Hi Bilal !

 

Thanks for confirming. I never did this before so I felt a bit unsecure. Are you experienced in writing DLLs in CVI for VB ?

0 Kudos
Message 5 of 7
(4,263 Views)
I have not created many C DLLs for use with VB 6.0 specifically. I usually end up working more with trying to use C DLLs created by someone else in VB 6.0. Tools like the include file generator or having a type library are great, just because it means less work for me :).

There are some VB 6.0 limitations that can make this challenging sometimes (VB 6.0 doesnt have int64's, no unsigned data types for example). But depending on the API, things usually move forward smoothly.






Bilal Durrani
NI
0 Kudos
Message 6 of 7
(4,237 Views)
Yesterday my colleague confirmed it's working. Cool ! Thanks for your support Bilal.
0 Kudos
Message 7 of 7
(4,224 Views)