LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem to access .tlb functions after 'create activeX controller'

Hello,
I have imported a .tlb file with the tool 'create ActiveX controller' into CVI. The result is a fp with all functions implemented in the dll (there is a tlb file and a dll) and 3 additional functions to load the dll (namely NewInameofdll, OpenInameofdll and ActiveInameofdll).

First I load the dll by calling NewInameofdll, then I call some functions of this dll. Loading seems not to cause any problem but calling the functions of this dll doesn't give any result. I don't get any error message in the ERRORINFO parameter. So I have no view of what is happening.

I think that this (third party) dll/tlb file is c++ code, and I think the functions in this dll are not defined as follow
<>. (I have seen and read this here:
http://zone.ni.com/devzone/conceptd.nsf/webmain/1d0c73348d50de5486256faf00614757?OpenDocument see How Can I Use DLLs Created in Visual C++ with LabWindows/CVI?).

Any suggestions how to solve this issue?
Is it indeed possible that the dll functions have not been defined using but that nevertheless CVI can find the function names and make a fp?
When exacly is this .tlb file important for loading the dll?

Thank you for the help!

Kristrio
0 Kudos
Message 1 of 3
(4,268 Views)
Howdy Kristrio,
 
The LabWindows/CVI ActiveX Controller Wizard creates a new instrument driver based off an ActiveX Server. When you use the wizard, you will arrive at a "Choose Server" window. This window polls the Windows registry for registered ActiveX servers and displays the type libraries for that ActiveX Server. Most COM (ActiveX) applications contain embedded libraries called type libraries which contain information (list of properties, methods, interfaces, etc) about your COM object.  The type library also provides information about the data types of each property and the return type and parameters of the object's methods.
 
In your case, it appears that the type library is not embedded in the ActiveX server but rather distributed as a side component.
 
The functions in your DLL could have been defined but not actually implemented which could cause the behavior of not seeing results from the functions. I would suggest contacting the vendor or even try calling this DLL in other environments. If you can successfully call that DLL in other environments, then we know it is an issue with CVI. 
 
 
Hope this helps!
 
Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 3
(4,232 Views)
Hallo Jonathan,
thank you for the reply. I have noticed that some lines of my message were hided (I put it between the 'smaller than' and 'bigger than' sign...) but you can find those lines in the source html file.

I found a solution to my problem. The code from the dll file was c++ code. So I created a wrapper in Visual C++ express, this created a .lib file and of course also a header file. I delared the functions in the wrapper .cpp file as follow:
extern "C" void __declspec(dllexport) myFunction(...){...}

and in the wrapper header file as follow:
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) void myFunction(...);
#ifdef __cplusplus
extern "C" }
#endif

This worked fine. I could import this function into LabWindows/CVI by simply including the header file (of course all dll and lib files needed to be in the linking path into CVI).

Kristof
0 Kudos
Message 3 of 3
(4,209 Views)