LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using tlb and DLL

Hi,

I was wondering how to use a tlb associated with a DLL in Labview.   I know the tlb has the function and bject prototypes and the DLL has the actual code.  Now question is, how do I create an object according to the tlb and the use this with the DLL?  Thanks

Yohan
0 Kudos
Message 1 of 21
(5,649 Views)
If it's a COM/ActiveX class, then you can use the ActiveX palette...start with Automation Open, then right click on the input reference terminal and "Select Class".
 
0 Kudos
Message 2 of 21
(5,641 Views)
Thanks, but the problem is how do I use the tlb file to define the function definitions of the dll?
0 Kudos
Message 3 of 21
(5,628 Views)
That's automatic. If it's a COM component, you need to ensure it's registered on your computer (typically using regsvr32.exe unless the installer put it in itself).

Then inside LabVIEW, you do what I said before - select class off of Automation Open.

If the tlb isn't registered w/ the COM component (it isn't in the list), then you can click the browse button to find it on the hard drive.

Once this is done, LabVIEW automatically reads it in. You might want to look at the examples in examples\comm for ideas on how you program with COM.
0 Kudos
Message 4 of 21
(5,622 Views)
thanks!  I'll take a look at that
0 Kudos
Message 5 of 21
(5,615 Views)
I have tried what you said and I still encounter a problem.  I open the automation, that works, but then I try to connect a method or property node to it and none are listed.  I am positive my tlb and dll are registered correctly.  What could be the problem?
Thanks again
0 Kudos
Message 6 of 21
(5,612 Views)
more specifically...

The .tlb contains an interface (eg: ITestInterface) that is implemented by the .dll using the (visual c++ 8.0)  "implement interface" on a class defined in the .dll (eg: CConcreteTest)

The project that created this is a visual studio 8 c++ .dll project.  There is one interface defined and a separate class that uses the "implement interface" option in vc8. 
--> when importing this .tlb and .dll into a visual c++ project: I use a COM smart pointer (of type ITestInterfacePtr) and call the CreateInstance() function using the name of implementing class.

Also,
 
This is the code to load the .dll and .tlb:
 
 

#import "..\drivers\vna\debug\vna.tlb" no_namespace

...

IcVNABASEDriverPtr pVNA;

HRESULT hr = pVNA.CreateInstance("VNA.RS_ZVC");

pVNA->setAddress(20);

...







0 Kudos
Message 7 of 21
(5,608 Views)
Could you post the tlb and dll?
0 Kudos
Message 8 of 21
(5,601 Views)
Here they are... you can probably guess these are for a Vector Network Analyzer driver 😉
Thanks
0 Kudos
Message 9 of 21
(5,590 Views)
Okay, I see the problem. When you open a COM object in LabVEIW via Automation Open, you specify the class you want to create (the CoClass in COM terminology). In this case, you select RS_ZVC.

However, Automation Open must return an interface, not a CoClass. So we look to the default interface for your class - which is IRS_ZVC. However, that interface has no methods (we filter out AddRef, etc. b/c you don't use them in LabVIEW).

You can use "Variant To Data" to convert the IRS_ZVC into the IcVNABASEDriver interface and then you get your methods (or change what you have set as the default interface). "Variant to Data" is effectively QueryInterface inside LabVIEW.

Hopefully that gets you going.
0 Kudos
Message 10 of 21
(5,583 Views)